如何在 Oreo 8.1 中隐藏软键盘。我正在使用这个,但不起作用
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
最佳答案
请使用以下方法您可能会得到修复。
public static void hideSoftKeyboard(Activity activity) {
InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (activity.getCurrentFocus() != null && activity.getCurrentFocus().getWindowToken() != null)
inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
}
关于java - 如何在新的更新 Oreo 8.1 中隐藏软键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49629227/