Skip to content Skip to sidebar Skip to footer

Skip Null Values In Listactivity With Sqlite Data

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

Solution 1:

Extend your SimpleCursorAdapter and check for null of the BORROWED val in your overrided bindView() method. Something like this:

privateclassmySimpleCursorAdapterextendsSimpleCursorAdapter{ 

    @OverridepublicvoidbindView(View view, Context context, Cursor cursor) {
             if ( cursor.isNull( cursor.getColumnIndex(BORROWED) ) ){
                   // Handle NULL scenario
             } else {
                   // Handle not NULL scenario
             }
    }
}

This is not tested and there's other code you'll need to implement, but this is the idea.

Solution 2:

You can apply where clause in db.query for non null values so that your cursor only has not null rows..

Post a Comment for "Skip Null Values In Listactivity With Sqlite Data"