如何申请多个过滤器上的适配器?多个、适配器、器上

由网友(后知后觉i)分享简介:我有一个ListView和调用我的适配器的用getFilter()。过滤(关键词)FUNC搜索字段。它的工作很不错,但我想补充一点,在搜索列表视图我的对象的不同标签的其它过滤器。I got a listView with and a search field that calls my Adapter's getF...

我有一个ListView和调用我的适配器的用getFilter()。过滤(关键词)FUNC搜索字段。 它的工作很不错,但我想补充一点,在搜索列表视图我的对象的不同标签的其它过滤器。

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?

谢谢

推荐答案

我想你自己实施的过滤器。当你不能让两个过滤器,你可以在它定义了要由应用类型的​​筛选(你可以使用过滤器中的多个过滤器)。

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.

或者

使用关键字来选择过滤器适用。添加的关键字的某些字符限定了过滤器应用的开始。随着 String.beginsWith()您可以检查哪些类型的过滤已经被应用。这必须在过滤器本身完成。在getFilter.filter(关键字)的调用方必须知道要在字符串前面加什么字。

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.

阅读全文

相关推荐

最新文章