Disabling of EditText in android

In my application I have an EditText. I want user just 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 up and I can change text.

What should I do? Thanks


I believe the correct would be to set android:editable="false" .

And if you wonder why my link point to the attributes of TextView , you the answer is because EditText inherits from TextView :

EditText is a thin veneer over TextView that configures itself to be editable.

Update:
As mentioned in the comments below, editable is deprecated (since API level 3). You should instead be using inputType (with the value none ).


use EditText.setFocusable(false) to disable editing
EditText.setFocusableInTouchMode(true) to enable editing;


Use this to disable user input

android:focusable="false"

android:editable="false" This method is deprecated one.

链接地址: http://www.djcxy.com/p/93382.html

上一篇: GridView的android布局会自动更改

下一篇: 在android中禁用EditText