您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。