Implementing Text Watcher for EditText

前端 未结 4 1193
北海茫月
北海茫月 2020-11-27 07:20

I have an EditText. When i click on it, it becomes focusable. I will type the input text to be entered into the EditText. I want to implement a listener for EditText, so tha

4条回答
  •  无人及你
    2020-11-27 07:29

    set edittext imeOption

    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    

    By using something like this,

    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                // Specify your database function here.
                return true;
            }
            return false;
        }
    });
    

    Alternatively, you can use the OnEditorActionListener interface to avoid the anonymous inner class.

提交回复
热议问题