当搜索提交隐藏键盘,或选择了搜索建议
问题描述:
我有一个操作栏搜索插件,提供搜索建议了。当在查询的用户类型和提交,或选择一个搜索建议,键盘不会消失。我怎样才能解决这个问题?
I have a action bar search widget that offers search suggestion too. When the user types in a query and submits it or chooses a search suggestion, the keyboard doesn't disappear. How can I resolve this issue?
我一直无法弄清楚如何隐藏在搜索键盘提交或建议进行选择。
I haven't been able to figure out how to hide the keyboard upon search submit or suggestion choose.
感谢您。
答
要隐藏输入法编辑器,使用 InputMethodManager
:
To hide the input method editor, use InputMethodManager
:
InputMethodManager imm=
(InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
您可以使用此从 onEditorAction()
,例如,如图的此示例项目。
You can use this from onEditorAction()
, for example, as shown in this sample project.