I want to implement search in my app, but I don't want to use a separate Activity to display my search results. Instead, I only want to use the suggestionslist that displays beneath the SearchView
.
I can use setOnQueryTextListener
on the SearchView
, listen for input and search for results. But how can I add these results to the list below the SearchView
? Let's just assume I'm searching in a List<String>
.
What you need to create is a Content Provider. In that way you can add custom results to your SearchView and add the autocomplete feature to it whenever the User inputs something.
If I don't remember incorrectly, in one of my projects I have done something similar, and it didn't take too long.
I believe this could be helpful: Turn AutoCompleteTextView into a SearchView in ActionBar instead
And also this: SearchManager - adding custom suggestions
Hope this helps.
N.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With