Cursor c = dbHelper.getMostRecent();
String[] from = new String[] { "name", "data", "thumb" };
int[] to = new int[] { R.id.activityName, R.id.activityData, R.id.activityThumb };
startManagingCursor(c);
SimpleCursorAdapter activities;
activities = new SimpleCursorAdapter(this, R.layout.activitywidget, c, from, to);
setListAdapter(activities);
In the second line, I grab the name, data, and thumb from the database. In the third line, I set these values for activityName (TextView), ActivityData (TextView) and ActivityThumb (ImageView).
It works great for "name" and "data", but I have no idea what to put for the "thumb". I have some images in / res / drawable /, but I'm not sure how to store them in the database (file path as a string? R.drawable.IMAGE_NAME as a string? Do I need to somehow save it as raw data ?)
Best scenario: I would just like to tell each activityThumb instance in the list which image path it should use as its resource.
EDIT: I figured this out by creating an implementation of SimpleCursorAdaptor and overriding bindView.
jdrea source
share