Filtering in array list Filterable Not cancelling the previous filter

一个人想着一个人 提交于 2019-12-23 10:53:45

问题


I have seen the filter method documentation which shows that calling the filter cancels all previous non-executed filtering requests and posts a new filtering request that will be executed later.

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     

回答1:


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.

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



来源:https://stackoverflow.com/questions/19159730/filtering-in-array-list-filterable-not-cancelling-the-previous-filter

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