您的位置:首页 > 移动开发 > Android开发

Android中EditText设置editable属性为不可编辑的问题

2015-06-11 14:25 459 查看
EditText的editable属性用于设置是否可被编辑,但目前已被deprecate,相关文档说用inputType属性替代,但实际上似乎又无效果,可能是个bug。


只能寻求其他方式实现EditText不可编辑的效果了。虽然editable还是可以运行。


android:editable="false"
should work, but
it is deprecated, you should be using
android:inputType="none"
instead.

[/code]

editable
is deprecated (since API level 3). You should instead be using

inputType
(with the value
none
).

android:editable is deprecated. android:inputType="none" should be used instead but it contains bug and it does not work.

<EditText ...
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
</EditText>


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);



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: