如何申请多个过滤器上的适配器? [英] How to apply multiple Filters on an Adapter?

查看:96
本文介绍了如何申请多个过滤器上的适配器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

这篇关于如何申请多个过滤器上的适配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆