如何使用CursorWrapper过滤光标行 [英] How to use CursorWrapper to filter Cursor rows

查看:271
本文介绍了如何使用CursorWrapper过滤光标行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要过滤掉基于特定条件的游标返回的某些行(这是我想从数据库接收的行后进行测试,因为它不容​​易将其添加到WHERE子句中的SQL查询)。我发现了以下相关问题: <一href="http://stackoverflow.com/questions/3027428/filter-rows-from-cursor-so-they-dont-show-up-in-listview">Filter从游标行,这样它们就不会在ListView中显示, 过滤光标以正确的方式?和<一href="http://stackoverflow.com/questions/2700172/how-to-hide-specific-rows-of-a-cursor-in-android">How隐藏在Android的游标的特定行。我想实现什么这些问题都在问。

I want to filter out some rows returned by a Cursor based on a specific condition (which I want to test after receiving the rows from the database, because it's not easy to add it to a WHERE clause in the SQL query). I found the following related questions: Filter rows from Cursor so they don't show up in ListView, Filtering a cursor the right way?, and How to hide specific rows of a Cursor in android. I want to implement exactly what those questions are asking.

虽然这些问题的答案展示如何实现一个CursorWrapper(我做了),我不知道该怎么然后链接了CursorWrapper光标和放大器; CursorAdapter的。这些问题的答案只是说然后,使用在SimpleCursorAdapter你CursorWrapper - 有人可以详细说明这是什么意思?具体来说,你在哪里实例化CursorWrapper类,你如何使用它结合CursorAdapter的?

While the answers to those questions show how to implement a CursorWrapper (which I have done), I don't know how to then link that CursorWrapper to the Cursor & CursorAdapter. The answers just say "Then, use your CursorWrapper in the SimpleCursorAdapter" - can someone elaborate on what this means? Specifically, where do you instantiate the CursorWrapper class and how do you use it in conjunction with the CursorAdapter?

感谢。

推荐答案

CursorWrapper 实施光标接口,所以你可以通过你的 CursorWrapper 您在的CursorAdapter 光标

CursorWrapper implements the Cursor interface, so you can pass your CursorWrapper to your CursorAdapter in place of your Cursor.

这篇关于如何使用CursorWrapper过滤光标行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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