Android Use Done button on Keyboard to click button

后端 未结 13 1337
-上瘾入骨i
-上瘾入骨i 2020-12-02 06:30

Ok in my app I have a field for the user to input a number. I have the field set to only accept numbers. When the user clicks on the field it brings up the keyboard. On the

13条回答
  •  青春惊慌失措
    2020-12-02 06:48

    Your Last Edittext .setOnEditorActionListener call this method automatic hit api

    I was Call in LoginActivity in et_password

     et_Pass.setOnEditorActionListener(new TextView.OnEditorActionListener() {
                public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                    if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) || (actionId == EditorInfo.IME_ACTION_DONE)) {
    
                        Log.i(TAG,"Enter pressed");
                        Log.i(Check Internet," and Connect To Server");
    
                    }
                    return false;
                }
            });
    

    Working Fine

提交回复
热议问题