```
Version:1.0StartHTML:000000201EndHTML:000029643StartFragment:000009894EndFragment:000029555StartSelection:000009894EndSelection:000029548SourceURL:https://www.jianshu.com/p/7c23db316a07
/*
*TODO Adapter
*/publicclassMyAdapterextendsRecyclerView.Adapter<RecyclerView.ViewHolder>{privateArrayList<BnBean.DataBean.CatalogBean>list;privateArrayList<String>imageer;privateContextcontext;publicMyAdapter(ArrayList<BnBean.DataBean.CatalogBean>list,ArrayList<String>imageer,Contextcontext){this.list=list;this.imageer=imageer;this.context=context;}@NonNull@OverridepublicRecyclerView.ViewHolderonCreateViewHolder(@NonNullViewGroupparent,intviewType){if(viewType==0){returnnewViewHolder1(LayoutInflater.from(context).inflate(R.layout.item_my_bn,parent,false));}else{returnnewViewHolder2(LayoutInflater.from(context).inflate(R.layout.item_my_list,parent,false));}}@OverridepublicvoidonBindViewHolder(@NonNullRecyclerView.ViewHolderholder,intposition){inti=getItemViewType(position);if(i==0){ViewHolder1holder1=(ViewHolder1)holder;holder1.bn.setImages(imageer).setDelayTime(2000).setImageLoader(newImageLoader(){@OverridepublicvoiddisplayImage(Contextcontext,Objectpath,ImageViewimageView){Stringp=(String)path;Glide.with(context).load(p).into(imageView);}}).start();}else{if(imageer.size()>0){position=position-1;}ViewHolder2holder2=(ViewHolder2)holder;holder2.tv.setText(list.get(position).getName());Glide.with(context).load(list.get(position).getIcon()).into(holder2.iv);}}@OverridepublicintgetItemCount(){if(imageer.size()>0){returnlist.size()+1;}else{returnlist.size();}}@OverridepublicintgetItemViewType(intposition){if(imageer.size()>0&&position==0){return0;}else{return1;}}publicclassViewHolder1extendsRecyclerView.ViewHolder{@BindView(R.id.bn)Bannerbn;publicViewHolder1(ViewitemView){super(itemView);ButterKnife.bind(this,itemView);}}publicclassViewHolder2extendsRecyclerView.ViewHolder{@BindView(R.id.iv)ImageViewiv;@BindView(R.id.tv)TextViewtv;publicViewHolder2(ViewitemView){super(itemView);ButterKnife.bind(this,itemView);}}}
```