只需在空白的LinearLayout添加点击事件即可,
点击事件的内容:
/*
* 处理键盘
*/
private void dealwithHiddenInputKeyBoard() {
InputMethodManager inputManager = (InputMethodManager) BookSearchActivity.this
.getSystemService(Context.INPUT_METHOD_SERVICE);
// check if no view has focus:
View view = BookSearchActivity.this.getCurrentFocus();
if (view != null) {
inputManager.hideSoftInputFromWindow(view.getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
}
}亲测成功。
本文介绍了一种在Android应用中隐藏软键盘的有效方法。通过在LinearLayout上添加点击事件,触发软键盘的隐藏,适用于需要频繁显示和隐藏键盘的场景。
470

被折叠的 条评论
为什么被折叠?



