简体   繁体   中英

Custom CursorAdapter to bind to simple_list_item_checked

For example, say I have a SQLite database of todos, each with a string title and an integer completed. How can I create a custom adapter (that extends CursorAdaper) that can bind the checkbox in an android.R.layout.simple_list_item_checked to the integer completed? I already know I have to convert the integer to a boolean, I'm using true = 1 and false = 0.

Please override the bindView abstract Method in your Adapter.

 /**
 * 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM