我正在尝试根据不同的状态更改特定行的颜色。这是我目前拥有的代码。
public View getView(int position, View convertView, ViewGroup parent) {
View row=convertView;
if (row==null) {
LayoutInflater inflater=getLayoutInflater();
row=inflater.inflate(R.layout.doit, parent, false);
}
TextView label = (TextView) row.findViewById(R.id.mess);
label.setText(ArrayAdapter.getItem(position));
switch(mState){
case STATE1:
label.setTextColor(Color.WHITE);
break;
case STATE2:
label.setTextColor(Color.BLACK);
break;
case STATE3:
label.setTextColor(Color.YELLOW);
break;
}
return(row);
}
}
代码有点工作..但它改变了所有的行。有任何想法吗?