In my application, I have an EditText that the user only has Read access not Write access.
In code I set android:enabled="false"
.
Although the background of EditText changed to dark, when I click on it the keyboard pops up and I can change the text.
What should I set to disable EditText?
As
android:editable="false"
is depricated.You can use InputType TYPE_NULL on EditTextuse like this :
For disable edit
EditText
, I think we can usefocusable
ORenable
butUsing
android:enabled=...
oreditText.setEnabled(...)
It also changes the text color in
EditText
to gray.When clicked it have no effect
Using
android:focusable=...
oreditText.setFocusable(false)
-editText.setFocusableInTouchMode(true)
It doesn't change text color of
EditText
When clicked it highlights the
EditText
bottom line for about few millisecondOutput
use
EditText.setFocusable(false)
to disable editingEditText.setFocusableInTouchMode(true)
to enable editing;Use
TextView
instead.This will make your edittext disabled.
And by using this
Will just make your Edittext not show your softkeyboard, but if it is connected to a physical keyboard, it will let you type.
To disable the functionality of an EditText, just use:
in case you want to enable it some way, then you can use: