package com.example.mountaintravel.base;

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

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

public abstract class MyBaseAdapter<T> extends BaseAdapter {
	private List<T> lists;
	protected LayoutInflater inflater;
	protected Context context;

	public MyBaseAdapter(Context context) {
		lists = new ArrayList<T>();
		this.context = context;
		inflater = LayoutInflater.from(context);
		// inflater=(LayoutInflater)
		// context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	
	public void addData(T t) {
		lists.add(t);
	}

	public void delData(T t) {
		lists.remove(t);
	}

	public void delData(int index) {
		lists.remove(index);
	}

	public void addDataList(List<T> l) {
		lists.addAll(l);
	}

	public void clear() {
		lists.clear();
	}

	public List<T> getLists() {
		return lists;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lists.size();
	}

	@Override
	public T getItem(int position) {
		// TODO Auto-generated method stub
		return lists.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public abstract View getView(int position, View convertView,
			ViewGroup parent);

}
