I am facing a problem of my filtered ListView not updating.
In my application there is a custom ListView which has a two TextView and one ImageView as a row elements.
The filter works fine but my custom ListView is not updated in publishResults()
.
@Override
protected FilterResults performFiltering(CharSequence constraint)
{
FilterResults results = new FilterResults();
if (constraint == null || constraint.length() <= 0) {
results.count = ListAdapter.this.mStringFilterList.size();
results.values = ListAdapter.this.mStringFilterList;
} else {
ArrayList<Ezomart> filterList = new ArrayList();
for (int i = 0; i < ListAdapter.this.mStringFilterList.size(); i++) {
if (((Ezomart) ListAdapter.this.mStringFilterList.get(i)).getTitle().toUpperCase().contains(constraint.toString().toUpperCase())) {
Ezomart country = new Ezomart();
country.setTitle(((Ezomart)ListAdapter.this.mStringFilterList.get(i)).getTitle());
Log.d("SRI",mStringFilterList.get(i).getTitle());
country.setSubCategory(((Ezomart) ListAdapter.this.mStringFilterList.get(i)).getSubCategory());
country.setArea(((Ezomart) ListAdapter.this.mStringFilterList.get(i)).getArea());
country.setThumbnailUrl(((Ezomart) ListAdapter.this.mStringFilterList.get(i)).getThumbnailUrl());
country.setNumber(((Ezomart) ListAdapter.this.mStringFilterList.get(i)).getNumber());
filterList.add(country);
}
}
results.count = filterList.size();
results.values = filterList;
}
return results;
}
protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
ListAdapter.this.ezoItems = (List<Ezomart>) filterResults.values;
if (filterResults.count > 0) {
notifyDataSetChanged();
} else {
notifyDataSetInvalidated();
}
}