从游标过滤行,使他们不ListView中显示 [英] Filter rows from Cursor so they don't show up in ListView

查看:116
本文介绍了从游标过滤行,使他们不ListView中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个光标,返回我用SimpleCursorAdapter用它来填充一个ListView行。我想过滤某些行,所以它们不会显示在我的ListView。我使用的数据来自其他地方我活动的行,所以我不想改变我的SQL将它们与一个过滤器WHERE子句。

I have a Cursor that returns rows I use with a SimpleCursorAdapter to populate a ListView. I would like to filter some of the rows so they don't get displayed in my ListView. I use the data from the rows elsewhere in my Activity so I don't want to change my SQL to filter them with a WHERE clause.

什么是保持一个行被显示在我的ListView最好的方法是什么?理想情况下我会检查一列在我的行,然后只行添加到满足条件的ListView控件。

What is the best way to keep a row from being displaying in my ListView? Ideally I would check a column in my row and then only add rows to the ListView that satisfy a condition.

推荐答案

创建一个 CursorWrapper 并覆盖动...()方法职位改在过滤的(这是什么的ListView 将看到)和岗位实际光标。然后,用你的 CursorWrapper SimpleCursorAdapter

Create a CursorWrapper and override the move...() methods to convert positions in the filtered set (which is what the ListView will see) and positions in the actual Cursor. Then, use your CursorWrapper in the SimpleCursorAdapter.

这篇关于从游标过滤行,使他们不ListView中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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