listview 隔行换色的方法

Adapter的getView中可以设置:
public static final int[] colors = new int[] { 0xffaabb, 0x0099ff};
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
int colorPos = position % colors.length;
view.setBackgroundColor(colors[colorPos]);
return view;
}

你可能感兴趣的:(listview 隔行换色的方法)