I am trying to implement a getFilter() on a base adapter to filter out search results on a List. Is there any example of how to implement a getFilter()?
MainActivity
in your adapter put this class to use it in getfilter method
//this is a simple class that filtering the ArrayList of strings used in adapter
public class filter_here extends Filter{
@Override
protected FilterResults performFiltering(CharSequence constraint) {
// TODO Auto-generated method stub
FilterResults Result = new FilterResults();
// if constraint is empty return the original names
if(constraint.length() == 0 ){
Result.values = Original_Names;
Result.count = Original_Names.size();
return Result;
}
ArrayList Filtered_Names = new ArrayList();
String filterString = constraint.toString().toLowerCase();
String filterableString;
for(int i = 0; i) results.values;
notifyDataSetChanged();
}
}
return instance from it in getfilter
@Override
public Filter getFilter() {
// TODO Auto-generated method stub
return filter;
}
full example