Question

How can I programatically hide the list of suggestions that pops up up below the SearchView?

There are times when I'd like the SearchView to not be inconified and to not have focus. I can do this both using the setIconified(false) and the clearFocus() methods respectively, but if the SearchView has any text in it, it will display the list of a search suggestions and I need to hide/suppress that.

Was it helpful?

Solution

Try to set an OnQueryTextListener to your search view, and return true on onQueryTextChange when you don't want any suggestions to show up.

OTHER TIPS

searchView.setSuggestionsAdapter(null); did that trick for me.

If you've set a SearchView.OnQueryTextListener on your SearchView, you can return false in onQueryTextSubmit.

This will make sure suggestions get closed/hidden whenever the user submits the search query (by clicking on a suggestion or the "search" button on the keyboard).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top