Frage

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.

War es hilfreich?

Lösung

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

Andere Tipps

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top