public class MyActivity extends Activity
{
private KeyListener listener;
private EditText editText; public void onCreate(...)
{
editText = ... // Get EditText from somewhere
listener = editText.getKeyListener(); // Save the default KeyListener!!!
editText.setKeyListener(null); // Disable input
} // When you click your button, restore the default KeyListener
public void buttonClickHandler(...)
{
editText.setKeyListener(listener);
}
}

Basically, you first save the EditText's default KeyListener before you call setKeyListener(null). Then, when you click your button, you call setKeyListener again, passing the default listener you previously saved.

以上是来自http://stackoverflow.com/questions/10933056/edit-text-key-listener问题中rainai的回答

好用。

EditText动态转换只读/编辑状态的更多相关文章

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

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

  2. EditText设置可以编辑和不可编辑状态

    1.首先想到在xml中设置android:editable="false",但是如果想在代码中动态设置可编辑状态,没有找到对应的函数 2.然后尝试使用editText.setFoc ...

  3. easyui 在编辑状态下,动态修改其他列值。

    首先是自定义了一个方法uodateColumn更新列值 /** *自定义的修改列值方法 */ $.extend($.fn.datagrid.methods, { updateColumn: funct ...

  4. [C1] C1ComboBox 的非编辑状态优化

    一.前言 先看看 WPF 自带的 ComboBox 在非编辑状态,自定义 ItemTemplate 的情况下,效果如下图所示: 其当前选中的项(红框内)与自定义的 ItemTemplate 一样: 但 ...

  5. WPF 编辑状态切换

    有时候DataGrid编辑的时候一个属性需要根据别的属性呈现不同的编辑状态.这就需要一个做一个状态切换.比如地址是1的时候,读写类型是读写.只读.只写.地址是2的时候,就只读.状态栏切换为TextBo ...

  6. MVC编辑状态两个DropDownList联动

    前几天使用jQuery在MVC应用程序中,实现了<jQuery实现两个DropDownList联动(MVC)>http://www.cnblogs.com/insus/p/3414480. ...

  7. DataGridView的DataGridViewComboBoxColumn列点击一次,自动处于编辑状态

    本文转载:http://www.cnblogs.com/Johnny_Z/archive/2012/02/12/2348235.html Winform中的DataGridView数据绑定控件有时会用 ...

  8. TFS中设置任务中的“计划开始时间”为可编辑状态

    问题现象 如果使用TFS系统的默认模板CMMI新建团队项目,你会发现在网页浏览器中,任务工作项的"计划开始日期"和"计划结束日期"的类型是普通字符,并且不能修改 ...

  9. Android EditText+ListPopupWindow实现可编辑的下拉列表

    使用场景 AutoCompleteEditText只有开始输入并且与输入的字符有匹配的时候才弹出下拉列表.Spinner的缺点是不可以编辑.所以本文介绍如何使用EditText+ListPopupWi ...

随机推荐

  1. PAT1054. The Dominant Color (20)

    #include <iostream> #include <map> using namespace std; int n,m; map<int,int> imgM ...

  2. Linux 通过进程Pid与端口互查

    ps -aux 状态详解 https://blog.csdn.net/whatday/article/details/54409387. linux下通过进程名查看其占用端口: https://www ...

  3. 转 : Java的版本特性与历史

    Java Versions, Features and History This article gives you a highlight of important features added i ...

  4. activity启动模式之singleTop

    activity启动模式之singleTop 一.简介 二.设置方法 在AndroidManifest.xml中将要设置为singleTop启动模式的页面进行配置 <activity andro ...

  5. netty的异常分析 IllegalReferenceCountException refCnt: 0

    netty的异常 IllegalReferenceCountException refCnt: 0 这是因为Netty有引用计数器的原因,自从Netty 4开始,对象的生命周期由它们的引用计数(ref ...

  6. 【C#笔札】1 string类型

    C中没有string这个类型,而是用字符串数组来实现,相对来说比较麻烦. LABVIEW相对来说要简单太多,毕竟他主要的精力集中在硬件控制上,软件操作方面极其简单. C#类似,C#中有System.S ...

  7. jQuery: Redirect to other URL

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> ...

  8. Selenium with Python 004 - 页面元素操作

    毫无疑问,首先需要导入webdriver from selenium import webdriver 清除文本 driver.find_element_by_id('kw').clear() 文本输 ...

  9. grep 查询包含内容的文件

    加入到 ~/.bashrc 或者 ~/.bash_profile bash export GREPF_FILES=/mnt/d/Developer:/mnt/e/Developer function ...

  10. Cassandra key说明——Cassandra 整体数据可以理解成一个巨大的嵌套的Map Map<RowKey, SortedMap<ColumnKey, ColumnValue>>

    Cassandra之中一共包含下面5种Key: Primary Key Partition Key Composite Key Compound Key Clustering Key 首先,Prima ...