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

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


  1. et_money.setOnEditorActionListener(new OnEditorActionListener() {

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


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("输入结束执行该方法", "输入结束");


        }

    });