Hide soft keyboard after dialog dismiss

前端 未结 8 1710
孤街浪徒
孤街浪徒 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 02:42

    All these advices to use InputMethodManager are somewhat vague - where exactly to call it,
    and they do not work at least for me.
    Yes, keyboard disappears but then the app crashes!?
    The main problem is that hiding of keyboard happens at the same time when dialog is disappearing.

    To avoid it dialog.dismiss() should be called in view.postDelayed() after imm.hideSoftInputFromWindow() and in my case I set delay as 150.

提交回复
热议问题