Hi I am having trouble figuring out how to hide the Android Virtual Keyboard after a search query with a search view. I want the keyboard to disappear when the user presses the return key (ideally when they tap anywhere outside the keyboard but I will settle for the return key for now). I have it working for a query using onQueryTextSubmit working:
public boolean onQueryTextSubmit(String s) {
//Search stuff...
searchView.clearFocus();
return true;
}
however I'd like it to also work if the query is an empty string. The problem is onQueryTextSubmit is not fired if it is an empty string: Android SearchView.OnQueryTextListener OnQueryTextSubmit not fired on empty query string
I'd also not like to use ActionBarSherlock so this solution will not do: Android SearchView empty string
I just want to hide the keyboard after a user searches :( it seems like such a simple problem but is giving me a headache. Any suggestions? Thanks!