问题: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. mybatisplus的坑 insert标签insert into select无参数问题的解决
  2. android中ImageView的ScaleType属性
  3. Android控件属性大全
  4. Linux android studio :'tools.jar' seems to be not in Android
  5. Android(安卓)android:scaleType属性 图片按比例缩放
  6. 解决TextView中MaxLines与ellipsize=end问题
  7. GestureOverlayView属性
  8. 修改Android系统属性SystemProperties.set("sys.powerctl", "shu
  9. Android属性之build.prop生成过程分析

随机推荐

  1. Android(安卓)studio3.6的JNI教程之hello
  2. android 使用TextView/EditText应该注意
  3. android browser 的几个小feature (四) k
  4. TextView字间距和行间距设置
  5. Android(安卓)Handler机制
  6. 使用AIDL实现Android的跨进程通信
  7. android checkbox,radiobox style自定义
  8. Phone拨号调起InCallUi流程(Phone 9.0 )(P
  9. android:configChanges属性总结
  10. Android(安卓)Drawable Importer的使用