How to hide soft keyboard on android after clicking outside EditText?

前端 未结 30 2315
醉话见心
醉话见心 2020-11-22 11:46

Ok everyone knows that to hide a keyboard you need to implement:

InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
imm.hi         


        
30条回答
  •  鱼传尺愫
    2020-11-22 12:30

    I got one more solution to hide the keyboard by:

    InputMethodManager imm = (InputMethodManager) getSystemService(
        Activity.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    

    Here pass HIDE_IMPLICIT_ONLY at the position of showFlag and 0 at the position of hiddenFlag. It will forcefully close the soft keyboard.

提交回复
热议问题