java - 自定义 CursorAdapter 绑定(bind)到 simple_list_item_checked

标签 java android sqlite cursor

例如,假设我有一个包含待办事项的 SQLite 数据库,每个待办事项都有一个字符串标题和一个完成的整数。如何创建一个自定义适配器(扩展 CursorAdaper),可以将 android.R.layout.simple_list_item_checked 中的复选框绑定(bind)到已完成的整数?我已经知道我必须将整数转换为 boolean 值,我使用 true = 1 和 false = 0。

最佳答案

请重写适配器中的bindView抽象方法。

 /**
 * Bind an existing view to the data pointed to by cursor
 * @param view Existing view, returned earlier by newView
 * @param context Interface to application's global information
 * @param cursor The cursor from which to get the data. The cursor is already
 * moved to the correct position.
 */
public abstract void bindView(View view, Context context, Cursor cursor);

关于java - 自定义 CursorAdapter 绑定(bind)到 simple_list_item_checked,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4486420/

相关文章:

android - ArrayAdapter 、 BaseAdapter 和 ListAdapter 有什么区别

安卓 fragment 动画

android - sqlite 插入表中选择 * 从

python - 使用 python 仅将 csv 文件中的特定行插入到 Sqlite3 数据库中

java - 同步访问队列

java - 生成随机条形码 - 一个设计问题

java - 列表/界面问题

Java相当于/usr/lib和/lib?

python - sqlite3.ProgrammingError : Incorrect number of bindings supplied. 当前语句使用 3,提供了 1

android - Marshmallow RelativeLayout 与 alignBaseline 行为异常