So after I set the filter on my listview:
//Log adapter count before filter
listView.getFilter().filter(searchStr)
//Log adapter count after filter
What I'm trying to achieve is to get the count of the result of that filtering. Like if before there are 10 items, then I apply the filter, so now only 5 items will appear, I want to get that count "5". I've tried checking the adapter count before and after the filter with no luck. They're displaying same count (I'm using a BaseExpandableListAdapter) if I apply filter, and if I apply filter again the number changes from before (but the before and after of filter is still the same).
Below is a sample result of what I'm getting on my logs:
Before filter the count is 10. After filter the count is 10.
Before filter the count is 8. After filter the count is 8.
I thought maybe my adapter doesn't get the reflected count right away but on the second filter, it changes the value, so I thought notifyDataSetChanged after the filter would make a difference, but it did not. Any help would be appreciated.
Thanks.
This is how I managed to do it:
myAdapter.getFilter().filter(searchText, new Filter.FilterListener() {
public void onFilterComplete(int count) {
Log.d("log", "result count:" + count);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With