I have a ListView that is populated with a cursor adapter. Each list item has a toggle button. When the user toggles the button, I want to update the corresponding row in the table for this cursor. But my adapter can populate the list with different cursors (for different images). I find the cursor.getNotificationUri () method, which works the way I need, except that it only supports API level 19, while my application supports API level 15.
Here is the event handler in MyCursorAdapter.java
viewHolder.toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int favourite = isChecked ? 1 : 0 ;
ContentValues value = new ContentValues();
Uri uri = cursor.getNotificationUri();
value.put(AmdmContract.SongEntry.COLUMN_FAVORITE, favourite);
mContext.getContentResolver()
.update(uri, value, where, selArgs);
}
});
Any help is greatly appreciated.
thank
source
share