这是我的代码
public View getDropDownView(int position, View view, ViewGroup parent) {
ViewHolder holder = null;
if(view==null)
{
view= inflater.inflate(R.layout.citylist, parent, false);
holder=new ViewHolder();
holder.txtTitle = (TextView) view.findViewById(R.id.tv);
holder.txtTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP,db.getSettings().getInt(15)-3);
holder.txtTitle.setPadding(10, 10, 10, 10);
view.setTag(holder);
}
else{
holder=(ViewHolder)view.getTag();
}
holder.txtTitle.setText(data.get(position));
if(position % 2 == 0)view.setBackgroundColor(Color.rgb(224, 224, 235));
return view;
}
当我在偶数行上滚动颜色时也出现在奇数行帮助
上答案 0 :(得分:1)
更改
if(position % 2 == 0)view.setBackgroundColor(Color.rgb(224, 224, 235));
到
view.setBackgroundColor(position & 1 == 0 ? Color.rgb(224, 224, 235) : android.R.color.transparent);