【发布时间】:2015-02-26 14:34:03
【问题描述】:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = layoutInflater.inflate(R.layout.statistics_adapter, parent, false);
}
textViewLeft= (TextView) view.findViewById(R.id.textView);
textViewRight= (TextView) view.findViewById(R.id.textView2);
imageView= (ImageView) view.findViewById(R.id.imageView);
textViewLeft.setText(title[position]);
textViewRight.setText(str[position]);
imageView.setVisibility(View.GONE);
if(position==(0)||position==(1)||position==(2)||position==(5)){
imageView.setVisibility(View.VISIBLE);
if (textViewRight.getText().equals("ok")) imageView.setImageResource(R.drawable.ok);
if (textViewRight.getText().equals("error")) imageView.setImageResource(R.drawable.error);
textViewRight.setText("");
}
if (position==8){
textViewRight.setTextColor(Color.parseColor("#ff0000"));
}
if (position>10){
textViewLeft.setText("");
}
return view;
}
在我的列表中,当您第一次向下滚动时,第 8 位的文本变为红色。如果您上下滚动 listView 5 次,那么我的文本将在 #ff0000 上改变颜色。我做错了什么?好像没问题
【问题讨论】:
标签: android android-layout android-activity view baseadapter