安卓的ListView做一个搜索过滤器 [英] Android: ListView making a search Filter
问题描述
有没有一种方法来创建搜索过滤器在使用BaseAdapter而不是ArrayAdapter,因为我只遇到过那些在有自定义列表视图使用ArrayAdapters方法,它们创造了我的自定义列表视图。 Follwing是我所遇到的<一个href="http://stackoverflow.com/questions/1737009/how-to-make-a-nice-looking-listview-filter-on-android">Making过滤器使用数组适配器
Is there a way to create a search filter over my custom list view which created using BaseAdapter rather than ArrayAdapter, because I have only come across methods that are using ArrayAdapters in there Custom List Views. Follwing is what I have come acrossMaking a filter using Array Adapter
推荐答案
如果你使用List集合再扩展ArrayAdapter - 这是BaseAdapter子类
If you're using List collection then extend ArrayAdapter - it's subclass of BaseAdapter.
覆盖getView方法(在你的情况只是复制旧getView $很少修改C $ C)。
Override getView method (In your case just copy your old getView code with little modifications).
对象,它是在您的收藏和一套覆盖的toString:
Override toString of object that is in your collection and set:
listView.setTextFilterEnabled(true);
这篇关于安卓的ListView做一个搜索过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!