Hide soft keyboard after dialog dismiss

前端 未结 8 1699
孤街浪徒
孤街浪徒 2021-01-31 02:16

I want to hide soft keyboard after AlertDialog dismiss, but it\'s still visible. Here is my code:

alert = new AlertDialo         


        
相关标签:
8条回答
  • 2021-01-31 03:04

    This works! This will close the keyboard after dialog dismiss

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    
    0 讨论(0)
  • 2021-01-31 03:06

    I met the same problem. Solved it by doing like this. It doesn't need any reference:

    imm.hideSoftInputFromWindow(getWindow().getDecorView()
                    .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    
    0 讨论(0)
提交回复
热议问题