0

我用以下代码填充我的 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;

如何设置颜色?

4

1 回答 1

0

你试过这个吗?(在返回 convertView 之前):

convertView.setBackgroundColor(Color.BLUE);//or another color
于 2013-05-27T15:22:38.350 回答