Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom search implementation with SearchView

Tags:

android

search

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

like image 909
nhaarman Avatar asked Oct 06 '22 06:10

nhaarman


1 Answers

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.

like image 63
N3sh Avatar answered Oct 10 '22 02:10

N3sh