How to disable EditText in Android

2020-02-07 19:24发布

How can I disable typing in an EditText field in Android?

16条回答
Bombasti
2楼-- · 2020-02-07 20:04

To disable a edittext in android:

editText.setEnabled(false);
查看更多
淡お忘
3楼-- · 2020-02-07 20:05

The XML editable property is deprecated since API LEVEL 15.

You should use now the inputType property with the value none. But there is a bug that makes this functionality useless.

Here you can follow the issue status.

查看更多
beautiful°
4楼-- · 2020-02-07 20:07

Assuming editText is you EditText object:

editText.setEnabled(false);
查看更多
迷人小祖宗
5楼-- · 2020-02-07 20:10

I think its a bug in android..It can be fixed by adding this patch :)
Check these links question 1 and question 2

Hope it will be useful.

查看更多
登录 后发表回答