我有一个很长的列表视图,我尝试更改特定单元格中的颜色,例如位置 == 0,它工作正常。但是当我向下滚动列表时,之前屏幕外的另一个单元格也发生了变化。任何想法?谢谢您的帮助
public class CheckWinNoAdapter extends ArrayAdapter<String> {
private final Context context;
private String[] values;
TextView tvMain;
public CheckWinNoAdapter(Context context, String[] values) {
// TODO Auto-generated constructor stub
super(context, R.layout.list_draw, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.list_draw, parent, false);
}
tvMain = (TextView) convertView.findViewById(R.id.chk_main);
tvMain.setText(values[position]);
if(position ==0){
tvMain.setTextColor(Color.BLUE);
}
return convertView;