How to make EditText not editable through XML in Android?

后端 未结 27 1903
梦谈多话
梦谈多话 2020-11-28 17:35

Can anyone tell me how to make an EditText not editable via XML? I tried setting android:editable to false, but

  1. it is de
27条回答
  •  醉酒成梦
    2020-11-28 18:17

    Let your Edittext be

    EditText editText;
    

    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.

提交回复
热议问题