I can show the id, title and borrowed values in a TextView. My problem is that I would like to check the “borrowed” values, and if they are not null, display a simple image. If the value is null, I don’t want to display anything.
Might work with a ViewBinder, but I don’t know how to solve this.
private static String[] FROM = { _ID, TITLE, BORROWED };
private static String[] TO = { R.id.id, R.id.title, R.id.borrowed };
private Cursor getMovies() {
SQLiteDatabase db = movies.getReadableDatabase();
Cursor cursor = db.query(TABLE_NAME, FROM, null, null, null, null, ORDER_BY);
startManagingCursor(cursor);
return cursor;
}
private void showTitles(Cursor cursor) {
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, FROM, TO);
setListAdapter(adapter);
}
Extend your SimpleCursorAdapter and check for null of the BORROWED val in your overrided bindView() method. Something like this:
This is not tested and there’s other code you’ll need to implement, but this is the idea.