花样奇案,豪情 淮山杞子,少年阿宾12
android:editable is deprecated: use an <edittext> to make it editable
android:editable is deprecated: use inputtype instead
分析:关于edittext控件的read-only问题,即: 无法通过ui更改其中的内容, 但可以选定部分内容, 进行复制.在早期的sdk, edittext有editable属性, 现在这个属性已经deprecated了.
解决方法:
其实只需一行代码就能搞定et.setkeylistener(null);
注意, 这里不是setonkeylistener, 而是setkeylistener. 此方法是textview的成员, 调用后的效果完全符合预期, 并且获得焦点后不会弹出输入法.
下面是官方文档的解释
sets the key listener to be used with this textview. this can be null to disallow user input. note that this method has significant and subtle interactions with soft keyboards and other input method: see keylistener.getcontenttype() for important details. calling this method will replace the current content type of the text view with the content type returned by the key listener.
be warned that if you want a textview with a key listener or movement method not to be focusable, or if you want a textview without a key listener or movement method to be focusable, you must call setfocusable again after calling this to get the focusability back the way you want it.
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Android studio开发小型对话机器人app(实例代码)
Android通过Java sdk的方式接入OpenCv的方法
Android 通过cmake的方式接入opencv的方法步骤
Android Studio finish()方法的使用与解决app点击“返回”(直接退出)
Android 进度条 ProgressBar的实现代码(隐藏、出现、加载进度)
网友评论