Search code examples
androidsearchview

How to show the search results in SearchView


I use toolbar searchview. I catch input result using code:

SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener() {
        public boolean onQueryTextChange(String newText) {

            return true;
        }

When I have the result I am looking for the similar strings in my excel file. Then I return ArrayList (search results). And now I need to show the results in SearchView. How can I do it?


Solution

  • You need to use a CursorAdapter associated with your searchview.

    Searchview.setSuggestionAdapter
    

    Helpful link about the usage of a cursor from an array (Create a cursor from hardcoded array instead of DB).