package com.example.mountaintravel.adapter;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.smart.gtstrvl.R;


import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;


/**
 * created anumbrella 2015 7 28
 * 
 * 左侧的数据适配器
 * */
public class ClassifyMainAdapter extends BaseAdapter {

	private Context context;
	private List<String> list;
	LayoutInflater mLayoutInflater;
	private int selectPosition = 0;// 默认第一个图片是选中了的
	public ClassifyMainAdapter(Context context,List<String> list) {
		super();
		this.mLayoutInflater = LayoutInflater.from(context);
		this.context=context;
		this.list=list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	public void setSelectItem(int position) {
		this.selectPosition = position;
	}

	public int getSelectItem() {
		return this.selectPosition;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(R.layout.item, parent, false);
		}
		CheckedTextView mView ;
		mView = (CheckedTextView) convertView.findViewById(R.id.item_text);
		mView.setChecked(false);
		if (position == selectPosition) {
			mView.setChecked(true);
		}
		mView.setText(list.get(position));
		return convertView;
	}
}
