我使用以下代码填充ListView:
final ListView lv = (ListView) findViewById(R.id.lvKinder);
ArrayList<Kind> kisi = datenfuerlistview();
KinderlistAdapter kiadapter = new KinderlistAdapter(this, kisi);
lv.setAdapter(kiadapter);
final DBHelper db = new DBHelper(this);
现在我想分析我添加到Kind
的每个ListView
对象的一个条目。如果它有一定值,我想更改此ListView
条目的backgroundcolor。
这是我的适配器:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if(convertView == null){
convertView = inflator.inflate(R.layout.list_black_text, parent, false);
holder = new ViewHolder((TextView) convertView.findViewById(R.id.nullline), (TextView) convertView.findViewById(R.id.firstLine), (ImageView) convertView.findViewById(R.id.imgv));
convertView.setTag(holder);
}
else{
holder = (ViewHolder) convertView.getTag();
}
Kind ki = (Kind) getItem(position);
holder.getName().setText(ki.getName());
holder.getDatum().setText(ki.getDatum());
Uri uri = Uri.parse(ki.getGeschlecht());
String path = ki.getKinderbild();
System.out.println("HSSSSSSSSSSSSSSSSSSSSSS" + path);
//holder.getGeschlecht().setImageBitmap(bitmap);
ContentResolver cr = context.getContentResolver();
Bitmap tmp = null;
try {
tmp = getThumbnail(cr, path);
} catch (Exception e) {
System.out.println("NAAAAAAAAAAAAAAAAAAAA") ;
e.printStackTrace();
}
holder.getGeschlecht().setImageBitmap(tmp);
return convertView;
如何设置颜色?
答案 0 :(得分:0)
convertView.setBackgroundColor(Color.BLUE);//or another color