如何文本过滤由 SimpleCursorAdapter 支持的 Android ListView? [英] How to text filter an Android ListView backed by a SimpleCursorAdapter?

查看:30
本文介绍了如何文本过滤由 SimpleCursorAdapter 支持的 Android ListView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由 SimpleCursorAdapter 支持的 ListView.

I have a ListView that is backed by a SimpleCursorAdapter.

我希望能够像过滤联系人列表一样过滤列表,只需输入即可,然后我遇到了 textFilterEnabled()

I'd like to be able to filter the list like you would a contacts list, just by typing, and I came across the textFilterEnabled()

问题是,我不知道如何让它与 SimpleCursorAdapter 一起工作.

Problem is, I couldn't see how to get it to work with a SimpleCursorAdapter.

这甚至可能吗?
如果有,是怎么做的?

Is this even possible?
If so, how is it done?

推荐答案

setTextFilterEnabled() 方法不会自动实现过滤,因为它不知道什么在您的 Cursor 中,应过滤文本.

The setTextFilterEnabled() method doesn't automatically implement filtering, as it doesn't know what in your Cursor the text should be filtered against.

这个android-developers thread有更多详细信息.

其实前几天问了一个很好的问题,其实和你的问题很相似;虽然它最初是询问当设备上没有物理键盘时如何处理过滤:

Actually, there was a good question asked the other day, which actually is very similar to your question; though it originally was asking how to handle filtering when there is no physical keyboard on a device:

这篇关于如何文本过滤由 SimpleCursorAdapter 支持的 Android ListView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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