EditText监听输入

来源:互联网 发布:计量经济学截面数据 编辑:程序博客网 时间:2024/06/07 05:40
来源:http://blog.csdn.net/com360/article/details/6616693

.使用TextWatcher类,这种方式是可以监听软键盘和硬键盘的,我们只需要实现onTextChanged方法即可,另外TextWatcher还提供了beforeTextChanged和afterTextChanged方法,用于更加详细的输入监听处理

java代码

 

    1. edittext.addTextChangedListener(new TextWatcher() {           
    2.             @Override  
    3.             public void onTextChanged(CharSequence s, int start, int before, int count) {  
    4.                 textview.setText(edittext.getText());  
    5.             }  
    6.               
    7.             @Override  
    8.             public void beforeTextChanged(CharSequence s, int start, int count,  
    9.                     int after) {                  
    10.             }  
    11.               
    12.             @Override  
    13.             public void afterTextChanged(Editable s) {                                
    14.             }  
    15.         });

 

0 0
原创粉丝点击