Hide keyboard when a search is submitted or a search suggestion is chosen
问题 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. Thank you. 回答1: To hide the input method editor, use InputMethodManager : InputMethodManager imm= (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v