(一)监听EditText输入内容变化

EditText.addTextChangedListener(textWatcher);

//EditText change listener
    //此方法会在初始化时自动执行一次
    private TextWatcher textWatcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    };

 

(二)EditText与软键盘交互

   //when the entry key is pressed   //此方法会执行两次,注意控制
        EditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                       return false;
            }
        });

相关文章:

  • 2022-12-23
  • 2021-07-12
  • 2021-12-02
  • 2022-01-15
  • 2022-01-16
  • 2021-09-30
猜你喜欢
  • 2021-12-12
  • 2022-02-06
  • 2021-07-31
  • 2021-08-15
  • 2021-11-17
  • 2022-02-12
  • 2021-05-17
相关资源
相似解决方案