Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Edittext after disabling it

OnButtonClick listener I want to disable the EditText to edit, and then turn it on again.

With below two lines I disabled EditText

 editTextWight.setEnabled(false);
 editTextWight.setFocusable(false);

But when I try to turn it back fails. The keyboard does not open.

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);
editTextWight.setClickable(true);
editTextWight.setEnabled(true);

Please help me to enable the EditText.

like image 538
Butterfly Avatar asked Nov 29 '25 02:11

Butterfly


1 Answers

You can try this two lines that work for my project code:

editTextWight.setFocusable(true);
editTextWight.setFocusableInTouchMode(true);

I do this for example afterTextChanged() is called because I had to disable this EditText first then enable it later!

So, just try it with ONLY two method calls above instead of all the four.

Good luck and let me know if it worked!

like image 85
Eenvincible Avatar answered Dec 01 '25 17:12

Eenvincible



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!