Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Auto complete Text view Editable or not-Editable? [duplicate]

I want to make Auto complete TextView Editable or not editable according to my condition.

I made Autocomplete text view as Editable

    constituency.setEnabled(true);
    constituency.setInputType(InputType.TYPE_CLASS_TEXT);
    constituency.setClickable(true);

but it's not working.
can anyone please help me?

like image 446
basha Avatar asked Jan 10 '18 10:01

basha


3 Answers

To disable an EditText (autocomplete or not) use editText.setInputType(0). See my answer in this post.

For re-enabling that EditText inquire the value of the input type prior to disabling it, save it in a variable, for example in int safe = editText.getInputType() and put the variable back in its place like so: editText.setInputType(safe). In order to regain focus, add editText.clearFocus() and editText.requestFocus().

like image 78
kalabalik Avatar answered Oct 16 '22 08:10

kalabalik


may be you are looking for this one.

education.setKeyListener(null);

for setting it back just put it in some method and call

education.setKeyListener(TextKeyListener.getInstance());
like image 38
vikas kumar Avatar answered Oct 16 '22 10:10

vikas kumar


You can just set constituency.setEnabled(boolean), to true or false.

like image 3
Tim K. Avatar answered Oct 16 '22 10:10

Tim K.