(一)监听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;
            }
        });

posted on 2013-08-02 14:46  Snow〃冰激凌  阅读(546)  评论(0编辑  收藏  举报