我有一个带有编辑文本的 fragment 。 当我单击edittext时,键盘出现。 问题是当我打开抽屉时,抽屉并没有隐藏键盘。 即使我切换到另一个 fragment ,键盘仍然显示。 打开抽屉时如何隐藏键盘。
我试着放
InputMethodManager imm =
(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getWindowToken(), 0);
和
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
两者都不隐藏键盘。
最佳答案
在打开/关闭滑动抽屉之前使用这行代码:
InputMethodManager inputMethodManager = (InputMethodManager) this.getSystemService(Activity.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
关于android - 抽屉导航在onDrawerOpened时隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17515839/