我用以下代码填充我的 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
条目的背景色。
这是我的适配器:
@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;
如何设置颜色?