4

I am trying to implement my first SearchView with suggestions. As far as I understand, I have two possibilities to provide suggestions:

  1. In the searchable.xml configure a custom content provider using android:searchSuggestAuthority which is then queried for suggestions (system calls query() method on the specified custom content provider)
  2. Or implement SearchView.OnQueryTextListener and provide the suggestions via SearchView.setSuggestionsAdapter

Did I understand that correctly? Am I correct that the second possiblity gives me the possiblity to handle the search logic inside a Fragment/ViewModel without creating a content provider as required for the first possiblity? Is there any advantage of one method over the other? Which one should I use? The Adding custom suggestions guide only mentions the first possiblity (using a custom ContentProvider), but that guide seems to be already quite old.

stefan.at.kotlin
  • 15,347
  • 38
  • 147
  • 270

0 Answers0