EditText: how to enable/disable input?

Firstly write these line in your xml in EditText:

android:enabled="false"

And than use the code in java as shown below:

Boolean check = true;
yourEditText.setEnabled(check);
check=!check;

I finally found a solution. It's a matter of calling

  • setFocusableInTouchMode(boolean)
  • setFocusable(boolean)

when the EditText is first created, so it can intercept the clicks. Then one can set those flags back again to make the EditText editable, request the focus, and manually show/hide the soft keyboard with InputMethodManager methods


Try using this setFocusableOnTouch() instead of setFocusable() method.