Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textview clickable false not working

How can i make textview Clickable false ? I tried with textView.setClickable(false) but it is not working i add my snippet below.

t1 = (TextView)findViewById(R.id.text_View1);

                t1.setClickable(false);
                //t1.setFocusableInTouchMode(false);
                //t1.setEnabled(false);

                t1.setFocusable(false);

                t1.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                        t1.setText("clicked");
                        }
                });

But when i click on textview text is change kindly help me.

like image 542
Madhav_nimavat Avatar asked Jan 05 '17 04:01

Madhav_nimavat


2 Answers

You need fully disable TextView:

t1.setEnabled(false);
like image 119
Sergey Bubenshchikov Avatar answered Oct 17 '22 17:10

Sergey Bubenshchikov


try to change the listener position like this

t1.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
         t1.setText("clicked");
     }
});
t1.setClickable(false);
//t1.setFocusableInTouchMode(false);
//t1.setEnabled(false);

t1.setFocusable(false);
like image 5
m 1987 Avatar answered Oct 17 '22 18:10

m 1987