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 的EditText实现不可编辑的更多相关文章

  1. android中将EditText改成不可编辑的状态

    今天在做项目的时候,要想实现一个将EditText变成不可编辑的状态,通过查找博客,发现一个好方法,对于单独的EditText控件我们可以单独设置 1.首先想到在xml中设置Android:edita ...

  2. Android限定EditText的输入类型为数字或者英文(包括大小写),EditText,TextView只能输入两位小数

    Android限定EditText的输入类型为数字或者英文(包括大小写) // 监听密码输入框的输入内容类型,不可以输入中文    TextWatcher mTextWatcher = new Tex ...

  3. Android开发EditText属性

    Android开发EditText属性 EditText继承关系:View-->TextView-->EditText EditText的属性很多,这里介绍几个:android:hint= ...

  4. Android之EditText组件学习

    一.基础学习 1.Button是TextView的一个子类,所以按钮本身是一个特殊的文本,属性和TextView相似 2.EditText类似html里的input type="text&q ...

  5. 【转】Android中EditText中的InputType类型含义与如何定义

    原文网址:http://www.crifan.com/summary_android_edittext_inputtype_values_and_meaning_definition/ 经过一些And ...

  6. Android锁定EditText内容和随机生成验证码

    昨天写了个小Demo,实现了随机生成验证码,和锁定EditText两个小功能,先看一下效果图: 锁定EditText在我们不须要用户编辑EditText内容的时候能够用到,实现还是非常easy的,一行 ...

  7. Android中Edittext的属性

    //此为转载别人的,挺不错的 1.EditText输入的文字为密码形式的设置 (1)通过.xml里设置: 把该EditText设为:android:password="true"  ...

  8. 【整理】Android中EditText中的InputType类型含义与如何定义( 转 )

    转自:[整理]Android中EditText中的InputType类型含义与如何定义 用到的时候查到了这篇文章觉得很不错,就在此记录下. [背景] 经过一些Android中EditText方面的折腾 ...

  9. Android自定义EditText去除边框并添加下划线

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

随机推荐

  1. uglifyjs压缩JS的

    一.故事总有其背景 年末将至,很多闲适的时间,于是刷刷微博,接触各种纷杂的信息——美其名曰“学习”.运气不错,遇到了一个新名词,uglifyjs. 据说是用来压缩JS文件的,据说还能优化JS,据说是基 ...

  2. 1064. Complete Binary Search Tree (30)

    分析: 考察BST + 完全二叉树的性质,注意: (1):先用排序排好,然后由于是完全二叉树,我们使用中序来建树. (2):建好之后,层次遍历可以采用队列. #include <iostream ...

  3. asp控件Repeater运用

    双层repeater嵌套 <asp:Repeater ID="rpt_dataRepeatgroup" runat="server" OnItemData ...

  4. Git 常用几个操作

    获取 git clone git@github.com:XXX/learning.git 更新 git pull  添加 git add XXX 上传本地 git commit -m "ap ...

  5. iOS开发零基础--Swift篇:Swift中数据类型

    Swift类型的介绍 Swift中的数据类型也有:整型/浮点型/对象类型/结构体类型等等 先了解整型和浮点型 整型 有符号 Int8 : 有符号8位整型 Int16 : 有符号16位整型 Int32 ...

  6. 如果我用C#来输出99表

    题目:参见这个链接,简单点说就是在控制台输出一个99乘方表. 无聊想了个C#版本的解答: private static void Print(int n) { var s = Enumerable.R ...

  7. bootstrap中实现外层DIV自适应,内层DIV宽度固定且居中的布局

    <!DOCTYPE html><html> <head> <link rel="stylesheet" href="css/bo ...

  8. Kali Linux Web 渗透测试视频教程—第十四课-arp欺骗、嗅探、dns欺骗、session劫持

    Kali Linux Web 渗透测试视频教程—第十四课-arp欺骗.嗅探.dns欺骗.session劫持 文/玄魂 目录 Kali Linux Web 渗透测试—第十四课-arp欺骗.嗅探.dns欺 ...

  9. 互联网上那些excel文件

    互联网上那些excel文件 文/玄魂 目录 互联网上那些excel文件 前言 1.1 查找包含指定值的excel文件 1.2 查找邮箱 1.3 查找身份证号 1.4  查找管理人员联系信息 1.5 获 ...

  10. 自定义Windows性能监视器

    Windows 性能监视器是一个很好用的自带监视工具,对于一些基本简单的监视需求可以轻松满足.本文主要总结了一下如何将自己应用中的一些性能数据暴露到性能监视器上方便管理. 什么?不知道什么是Windo ...