Android:过滤 SimpleCursorAdapter ListView
现在,我在尝试在自定义 SimpleCursorAdapter 中实现 FilterQueryProvider 时遇到了问题,因为我不确定在 FilterQueryProvider 的 runQuery 函数中要做什么。
换句话说,由于组成 ListView 的查询基本上从数据库表中获取 rowID、名称和第三列,因此我希望能够根据名称列的部分值来过滤游标。
但是,我不确定是否可以直接从 runQuery 执行此操作而不扩展我的数据库类,因为我想过滤现有游标,或者我是否必须在我的数据库类中创建一个新的查询函数来部分搜索我的名称列,并且如果是这样,我将如何在 runQuery 中使用 CharSequence 约束参数时创建查询语句?
我还担心与尝试基于部分文本运行多个查询相关的性能问题,因为相关数据库表大约有 1300-1400 行。换句话说,我在尝试过滤光标时会遇到瓶颈吗?
Right now, I'm running into issues trying to implement a FilterQueryProvider in my custom SimpleCursorAdapter, since I'm unsure of what to do in the FilterQueryProvider's runQuery function.
In other words, since the query that comprises my ListView basically gets the rowID, name, and a third column from my databases's table, I want to be able to filter the cursor based on the partial value of the name column.
However, I am uncertain of whether I can do this directly from runQuery without expanding my DB class since I want to filter the existing cursor, or will I have to create a new query function in my DB class that partially searches my name column, and if so, how would I go about creating the query statement while using the CharSequence constraint argument in runQuery?
I am also concerned about the performance issues associated with trying to run multiple queries based on partial text since the DB table in question has about 1300-1400 rows. In other words, would I run into a bottleneck trying to filter the cursor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要运行一个查询,该查询将返回一个新的过滤游标:
}
You need to run a query that will return a new filtered cursor:
}