All the tutorials point out that you need custom filter, since it is an adapter and it adds elements dynamically. Default Filter does not know how how to filter out elements by position (I don't know why).
The existing tutorials are pure SPAM. They're not working, this is a link for a working tutorial and the key point they point out is that Adapter has actually clear mehtod along with add() method you need to call when you publish results. Enjoy! 😇
https://www.mysamplecode.com/2012/07/android-listview-custom-layout-filter.html
protected void publishResults(CharSequence constraint,
FilterResults results) {
countryList = (ArrayList<Country>)results.values;
notifyDataSetChanged();
clear();
for(int i = 0, l = countryList.size(); i < l; i++)
add(countryList.get(i));
notifyDataSetInvalidated();
}
Top comments (0)