How Change Color/picture Of Specific One Listview Row - Android?
I am trying to change only one (maybe more) ListView row based on specific condition. I have read many answers on similar questions and tons of other tutorials but I am not able to
Solution 1:
Simply extend SimpleCursorAdapter and override bindView():
publicclassMyAdapterextendsSimpleCursorAdapter {
publicMyAdapter(Context context, int layout, Cursor c, String[] from, int[] to) {
super(context, layout, c, from, to);
}
@OverridepublicvoidbindView(View view, Context context, Cursor cursor) {
super.bindView(view, context, cursor);
if(cursor.getLong(cursor.getColumnIndex(MyDBAdapter.KEY_PRICE)) == 5)
view.setBackgroundColor(0xff00ff00);
else// this will be the default background color: transparent
view.setBackgroundColor(0x00000000);
}
}
Post a Comment for "How Change Color/picture Of Specific One Listview Row - Android?"