大家好,又见面了,我是全栈君,今天给大家准备了Idea注册码。
Android一个ListView列表之中插入两种不同的数据
public class ViewHolder{ Button fenzu_btn_1; Button fenzu_btn_2; Button fenzu_btn_3; } public class ViewHolder1{ TextView tvTitle; TextView tvLetter; } /** * 当ListView数据发生变化时,调用此方法来更新ListView * @param list http://www.cnblogs.com/roucheng/p/csslogin.html */ public void updateListView(List<SortModel> list){ this.list = list; notifyDataSetChanged(); } public int getCount() { return this.list.size(); } public Object getItem(int position) { return list.get(position); } @Override public int getItemViewType(int position) { // TODO Auto-generated method stub int p = position; if (p == 0) return 0; else return 1; } @Override public int getViewTypeCount() { return 2; } public View getView(final int position, View view, ViewGroup arg2) { int type = getItemViewType(position); if (view == null) { inflater = LayoutInflater.from(mContext); if(type==1){ view = inflater.inflate(R.layout.item,arg2, false); viewHolder1 = new ViewHolder1(); viewHolder1.tvTitle= (TextView) view.findViewById(R.id.title); viewHolder1.tvLetter= (TextView) view.findViewById(R.id.catalog); view.setTag(viewHolder1); }else{ //http://www.cnblogs.com/roucheng/p/csslogin.html view = inflater.inflate(R.layout.items2,arg2, false); fenzu_btn_1=(LinearLayout)view.findViewById(R.id.fenzu_btn_1); view.setTag(viewHolder); } } else { switch (type) { case 1: viewHolder1 = (ViewHolder1) view.getTag(); break; case 0: viewHolder = (ViewHolder) view.getTag(); break; } } return view; }
更多特效:http://www.cnblogs.com/roucheng/p/texiao.html
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/120636.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...