Which Adapter
are you using?
If you are using CursorAdapter
, then you can do it in your bindView()
. Here is a rough example code:
TextView tv = null;
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
tv = (TextView) v.findViewById(R.id.itemname);
}
@Override
public void bindView(View view, final Context context, final Cursor cursor) {
if(condition1){
tv.setBackgroundResource(R.color.white);
}else{
tv.setBackgroundResource(R.color.black);
}
}
If you are using any other Adapter, you can use the corresponding methods to apply the same logic.