listView隔行设置颜色重写SimpleAdapter

public class SpecialAdapter extends SimpleAdapter {  
    private int[] colors = new int[] { 0x30FF0000, 0x300000FF };  
  
    public SpecialAdapter(Context context, List> items, int resource, String[] from, int[] to) {  
        super(context, items, resource, from, to);  
    }  
  
    @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;  
    }  
}  

你可能感兴趣的:(Android开发相关)