Hiding keyboard after calling new Activity that shows a ProgressDialog

后端 未结 5 1413
误落风尘
误落风尘 2021-02-06 11:43

I\'m having trouble with the on screen keyboard. I have an activity with an EditText which shows the keyboard, and a button to go to a second activity. The second a

5条回答
  •  庸人自扰
    2021-02-06 12:14

    Solved using a variation of the technique posted by phalt:

    InputMethodManager im = (InputMethodManager) this.getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    im.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    

    This code works correctly during onCreate/onStart/onResume, since doesn't rely on a focused view to get the window token from.

提交回复
热议问题