Reputation: 59
trying to change a listView image item source depend on a field eg: if (status === 1) show red image else show green image. I tried a view binder with Simple Cursor Adapter, But that do nothing also not showing any error
private class MyViewBinder implements SimpleCursorAdapter.ViewBinder {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
int viewId = view.getId();
int status = cursor.getInt(cursor.getColumnIndex(LoanDb.KEY_STATUS));
ImageView noteTypeIcon = (ImageView) view;
if(viewId == R.id.status_img) {
switch (status) {
case 0:
noteTypeIcon.setImageResource(R.drawable.red_dot);
break;
case 1:
noteTypeIcon.setImageResource(R.drawable.green_dot);
break;
}
return true;
}else
{
return false;
}
}
}
this class located inside Main Activity as a child class, cant understand why this not working.
Upvotes: 0
Views: 97