基于 SimpleCursorAdapter 字段更改 ListView 项的背景颜色?
我有一个使用RelativeLayout的自定义ListView项目,看起来像这样...
| Time | Title |
| | Description |
注意:左侧的“时间”是一个全高TextView,其中“标题”和“描述”是单独的“堆叠”TextView。
ListView 项表示使用 SimpleCursorAdapter 从 SQLite DB 中提取的电视节目。这工作正常,但下一步是指示节目何时计划录制(该应用程序是基于 PC 的 PVR 应用程序的 Android 客户端)。
SQL 查询选择“start_time,title,description,is_set_to_record”,前三个是要绑定到 TextView 的文本字段,最后一个是布尔值。
看来我可能需要扩展 SimpleCursorAdapter 因此,如果“is_set_to_record”为 true,那么我将所有三个 TextView 的背景颜色设置为不同的颜色。问题是我不知道我应该在哪里做这件事。
这可能吗?如果是这样,任何指向我应该看的地方的指示将不胜感激。
I have a custom ListView item using RelativeLayout which looks like this...
| Time | Title |
| | Description |
NOTE: The lefthand 'Time' is a single full height TextView with 'Title' and 'Description being individual 'stacked' TextViews.
The ListView items represent TV programmes extracted from a SQLite DB with a SimpleCursorAdapter. This works fine but the next step is to indicate when a programme has been scheduled to record (the app is an Android client for a PC-based PVR application).
The SQL query selects 'start_time,title,description,is_set_to_record' the first three being text fields to bind to the TextViews and the last being boolean.
It seems I probably need to extend SimpleCursorAdapter so if 'is_set_to_record' is true then I set the background colour of all three TextViews to a different colour. The problem is that I don't know where I should be looking to do this.
Is this possible? If so, any pointers to where I should look would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在扩展的 SimpleCursorAdapter 中,您可以执行以下操作:
In your extended SimpleCursorAdapter you can do something like this.: