We can set editable property of EditText
in XML layout but not programatically, but there is no setEditable()
method!
If EditText
is not Enabled [ by setEnabled(false)
] it still Editable!
We can set editable property of EditText
in XML layout but not programatically, but there is no setEditable()
method!
If EditText
is not Enabled [ by setEnabled(false)
] it still Editable!
Fetch the KeyListener value of
EditText
byeditText.getKeyListener()
and store in the KeyListener type variable, which will contain the Editable property value:Set the Editable property of
EditText
to false as:Now set Editable property of
EditText
to true as:Note: In XML the default Editable property of
EditText
should be true.Since
setEditable(false)
is deprecated, usetextView.setKeyListener(null);
to make editText non-clickable.How to do it programatically :
To enable EditText use:
To disable EditText use:
hope this one helps you out:
Once focus of edit text is removed, it would not allow you to type even if you set it to focusable again.
Here is a way around it
Setting it true in
setFocusableInTouchMode()
seems to do the trick.