package cn.net.caoyao.cpzshandset.ui.adapter;

import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import cn.net.caoyao.cpzshandset.R;
import cn.net.caoyao.cpzshandset.bean.DealerInfoBean;

public class DealerAdapter extends BaseAdapter {
	private List<DealerInfoBean> datas;


	public DealerAdapter(List<DealerInfoBean> datas) {
		this.datas = datas;
	}

	public void refreshData(List<DealerInfoBean> datas) {
		this.datas = datas;
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {

		return datas.size();
	}

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

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

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;

		if (convertView == null) {
			convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_text_item_layout, parent,
					false);
			holder = new ViewHolder();
			holder.mTextView = (TextView) convertView.findViewById(R.id.tv_single_text_item);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.mTextView.setText(datas.get(position).getName() + "");
		return convertView;
	}

	public static class ViewHolder {
		public TextView mTextView;
	}

}
