I m trying to use searchView with LazyList. In my lazyAdapter I m updating my arraylist , this works smoothly but my listview doesn't update with arrayList. This is my filer method. I suppose notifyDataSetChanged does not work.Please help how can I refresh my listview?
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
//list.clear();
list = new ArrayList<HashMap<String, String>>();
if (charText.length() == 0) {
list.addAll(arraylist);
}
else
{
for (HashMap<String, String> map : arraylist)
{
if (map.get("radio").toString().toLowerCase(Locale.getDefault()).contains(charText))
{
list.add(map);
}
}
}
notifyDataSetChanged();
}
The variable list
holds a different object after the third line. You are changing this new ArrayList
but the adapter still remembers the old one. Instead of
list = new ArrayList<HashMap<String, String>>();
write
list.clear();
You then work with the same object as before.