문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top