EditText动态监听

原网址:http://blog.csdn.net/sinat_35241409/article/details/53709537

1、EditText输入框的动态监听方法

A:监听 输入结束点击键盘确认键执行的 方法

  1. et_money.setOnEditorActionListener(new OnEditorActionListener() {  
  2.           
  3.         @Override  
  4.         public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {  
  5.             Log.e("输入完点击确认执行该方法", "输入结束");  
  6.             return false;  
  7.         }  
  8.     });  
et_money.setOnEditorActionListener(new OnEditorActionListener() {
        
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            Log.e("输入完点击确认执行该方法", "输入结束");
            return false;
        }
    });

B:动态跟随键盘输入的监听方式

et_money.addTextChangedListener(new TextWatcher() {
        
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // 输入的内容变化的监听
            Log.e("输入过程中执行该方法", "文字变化");
        }
        
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // 输入前的监听
            Log.e("输入前确认执行该方法", "开始输入");
            
        }
        
        @Override
        public void afterTextChanged(Editable s) {
            // 输入后的监听
            Log.e("输入结束执行该方法", "输入结束");
            
        }
    });


原文地址:https://www.cnblogs.com/CCCrunner/p/11781783.html