Can anyone tell me how to make an EditText
not editable via XML? I tried setting android:editable
to false
, but
- it is deprecated; and
- it didn't work.
Can anyone tell me how to make an EditText
not editable via XML? I tried setting android:editable
to false
, but
I tried to do:
which should work, but for me it did not.
I finished with this code:
which works perfectly.
You could use
android:editable="false"
but I would really advise you to usesetEnabled(false)
as it provides a visual clue to the user that the control cannot be edited. The same visual cue is used by all disabled widgets and consistency is good.Try
I use
EditText.setFocusable(false)
and set true again if I want to edit.Let your Edittext be
editText.setKeyListener(null);
will work but it just not listening to keys.
User can see a cursor on the edittext.
You can try
editText.setEnabled(false);
That means user cannot see the cursor. To simply say it will became
TextView
.This way did the job for me, i can selec and copy to clipboard, but i can't modify or paste.