package com.example.mountaintravel.adapter;



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

import com.smart.gtstrvl.R;


import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckedTextView;

import android.widget.TextView;

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

	private List<Map<String,String>> listMore;
	private Context mContext;
	private int selectPosition = 0;// 默认选中第一个
	private Hoder hoder;

	public ClassifyMoreAdapter(Context context, List<Map<String,String>> list) {
		this.listMore = list;
		this.mContext = context;
	}

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

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

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

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

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

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			convertView = View.inflate(mContext,
					R.layout.item_classify_morelist, null);
			hoder = new Hoder(convertView);
			convertView.setTag(hoder);
		} else {
			hoder = (Hoder) convertView.getTag();
		}
		String str=listMore.get(position).get("RuKouIdAllRoad");
		 String[] strarray=str.split("a"); 
		hoder.textView.setText("线路名称："+strarray[0]+"\n难易程度："+strarray[4]
				+"\n总里程："+strarray[1]+"米\n总耗时："+strarray[2]+"分\n消耗卡路里："
				+strarray[3]+"卡");
		hoder.textView.setChecked(false);
		if (position == selectPosition) {
			hoder.textView.setChecked(true);
			
		}

		return convertView;
	}

	private static class Hoder {
		private CheckedTextView textView;
		public Hoder(View view) {
			textView = (CheckedTextView) view.findViewById(R.id.moreItem_text);
		}

	}

}
