Android detect Done key press for OnScreen Keyboard

后端 未结 3 1998
渐次进展
渐次进展 2020-11-27 14:21

Is it possible to detect when the Done key of onScreen keyboard was pressed ?

3条回答
  •  隐瞒了意图╮
    2020-11-27 15:01

    An Editor Info is most useful class when you have to deal with any type of user input in your Android application. For e.g. in login/registration/search operations we can use it for more accurate keyboard input. An editor info class describes several attributes for text editing object that an input method will be directly communicating with edit text contents.

    You can try with IME_ACTION_DONE .

    This action performs a Done operation for nothing to input and the IME will be closed.

    Using setOnEditorActionListener

    EditTextObj.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                /* Write your logic here that will be executed when user taps next button */
                handled = true;
            }
            return handled;
        }
    });
    

提交回复
热议问题