在数组列表中过滤可过滤不取消之前的过滤器 [英] Filtering in array list Filterable Not cancelling the previous filter

查看:164
本文介绍了在数组列表中过滤可过滤不取消之前的过滤器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

>但是我收到的实际回调是有些不同。在我的实现中,不取消之前的过滤请求,并在之前的搜索条件调用 publishResults()方法最近的搜索标准。日志如下:

But the actual callback which i received is some how different.In my implementation it is not cancelling the previous filter request and calls the publishResults() method for the previous search criteria after the recent search criteria .The logs are as follows:

  10-03 17:49:41.781: E/TAG(2150): onTextChanged first Criteria  
  10-03 17:49:41.781: E/TAG(2150): performFiltering first Criteria  
  10-03 17:49:41.961: E/TAG(2150): onTextChanged second Criteria   
  10-03 17:49:41.961: E/TAG(2150): performFiltering second Criteria  
  10-03 17:49:42.195: E/TAG(2150): publishResults second Criteria   
  10-03 17:49:42.219: E/TAG(2150): publishResults first Criteria     


推荐答案

您必须在适配器中仅使用一个 Filter 的单个实例,以便能够取消先前未执行的过滤请求。每次调用 getFilter 时,请勿创建 Filter的新实例

You have to use only one single instance of Filter in your adapter to be able to cancel any previous non-executed filtering request. Don't create a new instance of Filter every time getFilter is called.

例如,在适配器初始化时进行初始化,并从 getFilter 方法返回。

For example, initialize it on adapter initialization, and just return it from getFilter method.

这篇关于在数组列表中过滤可过滤不取消之前的过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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