问题:android:editable is deprecated: Use an to make it editable


意思:Android的:编辑是反对:使用<</span>EditText>对其编辑


分析:关于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.


更多相关文章

  1. Android android:scaleType属性 图片按比例缩放
  2. GestureOverlayView属性
  3. 关于那些Android中不常用的设置属性
  4. TextView 属性

随机推荐

  1. 厌倦了excel绘制地图的繁琐操作,来看看这
  2. 3种方法,隐藏苹果Mac档案、资料夹
  3. Kubernetes日志系统新贵Loki-Stack
  4. Kubernetes Scheduler浅析
  5. Centos7 下安装NFS+Heartbeat+DRBD
  6. 0基础如何学习Python课程?就业前景怎么样
  7. JDK9对String字符串的新一轮优化,不可不知
  8. GitOps之Argo CD实践
  9. Kubernetes应用管理器OpenKruise之CloneS
  10. 运维岗转开发岗,学Python还是Java?