arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 667 forks source link

Implementing Suggestions #328

Closed jabi1995 closed 5 years ago

jabi1995 commented 5 years ago

I have a list of Strings fetched from local database How can I use this list as suggestion in FSV? In your example I watched you convert Json format to ColorWrapper but How about mine?

Regards

mosesmwongela commented 5 years ago

Do this.

  1. Create an entity class for your String. Something like: https://raw.githubusercontent.com/arimorty/floatingsearchview/master/sample/src/main/java/com/arlib/floatingsearchviewdemo/data/ColorSuggestion.java

  2. Create an ArrayList of type "your entity"

  3. Populate this arrayList

  4. Pass this list to the FSV this way: mSearchView.swapSuggestions(newSearchSuggestions);

I hope this helps