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.common.config.HandsetSettingOption;

public class SettingAdapter extends BaseAdapter{
	private List<HandsetSettingOption> beans;
	public SettingAdapter(List<HandsetSettingOption> beans) {
		this.beans = beans;
	}

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

	@Override
	public Object getItem(int position) {
		return beans.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.adapter_setting_item, parent, false);
			holder = new ViewHolder();
			holder.btn_setting_item = (TextView) convertView.findViewById(R.id.btn_setting_item);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.btn_setting_item.setText(beans.get(position).getSettingOptionName());
		
		return convertView;
	}
	
	private class ViewHolder{
		private TextView btn_setting_item;
	}

}
