package com.qiyou.mb.android.utils;

import com.qiyou.mb.android.R;

import android.content.Context;
import android.database.Cursor;
import android.graphics.Color;
import android.support.v4.widget.SimpleCursorAdapter;
import android.view.View;
import android.view.ViewGroup;

public class QCursorAdapter extends SimpleCursorAdapter{	
	
 public QCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags) 
{
	super(context, layout, c, from, to);
	// TODO Auto-generated constructor stub
}
//int[] colors={R.color.floralwhite,R.color.white };
//int[] colors={R.color.lightcyan,R.color.ivory };//R.color.lightcoral
 int[] colors={R.color.ivory,R.color.snow };//R.color.lightcoral
//int[] colors={R.color.lightgray,R.color.lightpink };
//int[] colors={R.color.springgreen,R.color.silver }; 
//int selectedColor=R.color.cyan;//R.color.blanchedalmond;
 int selectedColor=R.color.silver;

@Override 
public View getView(int position, View convertView, ViewGroup parent){
	
//	if (position == selectItem) {
//		convertView.setBackgroundColor(Color.RED);
//	} 
//	else {
//		convertView.setBackgroundColor(Color.TRANSPARENT);
//	}	
//	 
	
	View v =super.getView(position, convertView, parent);  
	v.setBackgroundResource(colors[position%2]);
//    v.setBackgroundColor(colors[position%2]); 
    if (position == selectItem) {
		v.setBackgroundResource(selectedColor);
//    	v.setBackgroundColor(Color.parseColor("#95AC5F"));
	} 
    
	return v; 
}

public  void setSelectItem(int selectItem) {
	 this.selectItem = selectItem; 
//	 View v =super.getView(selectItem, null, null);  
// 
//	 v.setBackgroundResource(selectedColor);
	 
}
private int  selectItem=-1;
	
 }