【发布时间】:2013-01-15 17:05:18
【问题描述】:
所以在我在列表视图上设置过滤器后:
//Log adapter count before filter
listView.getFilter().filter(searchStr)
//Log adapter count after filter
我想要实现的是获取该过滤结果的计数。就像之前有 10 个项目,然后我应用过滤器,所以现在只会出现 5 个项目,我想得到那个计数“5”。我尝试在过滤器之前和之后检查适配器计数,但没有成功。如果我应用过滤器,它们将显示相同的计数(我正在使用 BaseExpandableListAdapter),如果我再次应用过滤器,数字会从之前发生变化(但过滤器的前后仍然相同)。
以下是我在日志中得到的示例结果:
Before filter the count is 10. After filter the count is 10.
Before filter the count is 8. After filter the count is 8.
我想也许我的适配器没有立即获得反射计数,但是在第二个过滤器上,它会更改值,所以我认为过滤器之后的 notifyDataSetChanged 会有所不同,但事实并非如此。任何帮助将不胜感激。
谢谢。
【问题讨论】:
标签: android filter android-listview filtering android-adapter