I am trying to implement this search box to my project. I need to create a list which includes all the suggestions when the user type some text in the text area but I am stuck.
The list I need to create has this form:
List<? extends SearchSuggestion>
and SearchSuggestion is an interface which extends Parcelable :
import android.os.Parcelable;
public interface SearchSuggestion extends Parcelable{
String getBody();
}
I guess I have to create a class which implements SearchSuggestion and put some values there?
Something like this?
public class MyClass implements SearchSuggestion {
public String mystring;
public MyClass(String text){
this.mystring = text;
}
}
I really don't have any idea how to proceed with this problem. I don't know what else to post here to help you help me, so if you need anything just tell me.
When you implement SearchSuggestion
it gives you the method String getBody();
Therefore your object would look like this:
public class MyClass implements SearchSuggestion {
private final String myString;
public MyClass(String text){
this.myString = text;
}
@Override
public String getBody() {
return myString;
}
}
Also your list does not need a wildcard (?
) it can just be:
List<SearchSuggestion>
All of this is explained in the ReadMe of the repo you linked:
https://github.com/arimorty/floatingsearchview/blob/master/README.md
it has a demo that does what you are looking for:
&
&
Showing that you add your suggestions like this:
searchView.swapSuggestions(yourListOfSuggestions);