How to apply multiple Filters on an Adapter?

北战南征 提交于 2019-12-01 09:45:52

问题


I got a listView with and a search field that calls my Adapter's getFilter().filter(keyword) func. It is working very nice, but i would like to add an other filter that searches in different tags of my listViews's objects.

So i need two filters for my Adapter, whats the best solution for this?

Thanks,


回答1:


I suppose that you implemented the filter yourself. As you cant get two filters you could have a field in the filter that defines what kind of filtering should by applied ( you could use multiple filters in your filter).

Set you field of the filter to the value you want before using the filter.

Or:

Use the keyword to choose the filter to apply. Add on the beginning of the keyword some characters which define the filter to apply. With String.beginsWith() you can check which type of filtering has to by applied. This has to be done in the Filter itself. The caller of the getFilter.filter(keyword) has to know what characters have to by added in front of the string.




回答2:


Apply Multiple Filter in Listview and also use the multi sorting in ListView, try this link:

https://github.com/apurv3039/filter_listview/tree/master



来源:https://stackoverflow.com/questions/11390890/how-to-apply-multiple-filters-on-an-adapter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!