例如,假设我有一个todos的SQLite数据库,每个都有一个字符串标题和一个完整的整数。如何创建一个自定义适配器(扩展CursorAdaper),它可以将android.R.layout.simple_list_item_checked
中的复选框绑定到已完成的整数?我已经知道我必须将整数转换为布尔值,我使用的是true = 1和false = 0.
答案 0 :(得分:1)
请覆盖适配器中的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);