您好,登錄后才能下訂單哦!
import java.util.ArrayList; import java.util.List; import java.util.Map; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.LinearLayout; public abstract class BaseHolderAdapter extends BaseAdapter{ LayoutInflater mInfalter; Context mContext; List<Map<String,Object>> mDatas; int mLayoutID; public BaseHolderAdapter(Context aContext,int layoutID){ mContext = aContext; mLayoutID = layoutID; mInfalter = LayoutInflater.from(aContext); mDatas = new ArrayList<Map<String,Object>>(); } public void setData(List<Map<String,Object>> list,boolean isRel){ if (list == null) return; if( isRel ){ mDatas = list; }else{ mDatas.addAll(list); } notifyDataSetChanged(); } public void cleanDatas(){ mDatas.clear(); } @Override public int getCount() { return mDatas.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { Item item = null; if( convertView == null ){ item = new Item(mContext); }else{ item = (Item) convertView; } itemViewSetData(item,position); return item; } abstract void itemInit(View view); abstract void itemViewSetData(View view,int position); class Item extends LinearLayout{ public Item(Context context) { super(context); mInfalter.inflate(mLayoutID, this); itemInit(this); } } }
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。