我想更改我的列表视图的背景颜色。 从数字背景应该由状态Android的更改列表中的项目与自定义适配器的列表视图
1 = red
2 = grey
3 = green
4 = yellow
这就是从我的自定义适配器更改代码(不工作):
TextView number = (TextView) rowView.findViewById(R.id.tv_number);
switch(Integer.parseInt(status[position])){
case 1: number.setBackgroundColor(0xff0000);
break;
case 2: number.setBackgroundColor(0xdfdfdf);
break;
case 3: number.setBackgroundColor(0x00ff00);
break;
case 4: number.setBackgroundColor(0xffff00);
break;
default :
break;
}
为什么它不工作?
什么是status []?您可以直接通过位置切换案例。 – 2014-09-29 10:49:21
status [position] = 1,2,3或4改变背景颜色 – rapha31 2014-09-29 10:55:24
你想改变listview背景或列表项背景吗? – 2014-09-29 10:59:16