How to clear focus and remove keyboard on Android?

后端 未结 6 2064
情歌与酒
情歌与酒 2021-02-01 18:41

I have a EditText control. If I tap it the softkeyboard will popup however when I press \"enter/ok/return\" then the EditText control it still has focus and the keyboard up.

6条回答
  •  故里飘歌
    2021-02-01 19:17

    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editTextField.getWindowToken(), 0);
    

提交回复
热议问题