import java.util.LinkedList; 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 class MyBaseAdapter<T> extends BaseAdapter { protected Context mContext; protected LayoutInflater mInflater; protected List<T> mDatas = new LinkedList<T>(); public MyBaseAdapter(Context context, List<T> datas) { mContext = context; mInflater = LayoutInflater.from(context); if (datas != null) { mDatas = datas; } } public void addItemLast(List<T> datas) { mDatas.addAll(datas); } public void addItemTop(List<T> datas) { mDatas = datas; } @Override public int getItemViewType(int position) { return super.getItemViewType(position); } @Override public int getViewTypeCount() { return super.getViewTypeCount(); } public MyBaseAdapter(Context context, List<T> datas,int round) { mContext = context; mInflater = LayoutInflater.from(context); if (datas != null) { mDatas = datas; } } @Override public int getCount() { int count=0; if(mDatas.size()>0){ count=mDatas.size(); } return count; } @Override public Object getItem(int position) { return mDatas.get(position); } @Override public long getItemId(int position) { return position; } public List<T> getDatas() { return mDatas; } @Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub return null; } }
时间: 2024-12-19 02:40:43