Package Com.example.administrator.ls.adapter;import Android.content.context;import Android.support.v7.widget.recyclerview;import Android.view.layoutinflater;import Android.view.View;import Android.view.viewgroup;import Android.widget.baseadapter;import Android.widget.imageview;import Android.widget.textview;import Com.example.administrator.ls.itembean;import COM.EXAMPLE.ADMINISTRATOR.LS.R; Import java.util.List; Public classMyadapter extends Baseadapter {PrivateList<itembean>mlist; PrivateLayoutinflater Minflater; PublicMyadapter (Context context,list<itembean>list) {mlist=list; Minflater=layoutinflater. from(context); } @Override Public intGetCount () {returnmlist.size (); } @Override PublicObject GetItem (intposition) { returnMlist.Get(position); } @Override Public LongGetitemid (intposition) { returnposition; } @Override PublicView GetView (intposition, View Convertview, ViewGroup parent) {Viewholder viewholder; if(convertview==NULL) {Viewholder=NewViewholder (); Convertview=minflater.inflate (R.layout.activity_item,NULL); Viewholder.imageview=(ImageView) Convertview.findviewbyid (r.id.iv_image); Viewholder.title=(TextView) Convertview.findviewbyid (r.id.tv_title); Viewholder.content=(TextView) Convertview.findviewbyid (r.id.tv_content); Convertview.settag (Viewholder); } Else{Viewholder=(Viewholder) Convertview.gettag (); } Itembean Bean= Mlist.Get(position); Itembean Itembean= Mlist.Get(position); ViewHolder.imageView.setImageResource (ITEMBEAN.ITEMIMAGERESID); ViewHolder.title.setText (Itembean.itemtitle); ViewHolder.content.setText (itembean.itemcontent); returnConvertview; }}classviewholder{ PublicImageView ImageView; PublicTextView title; PublicTextView content;}
Andro Adapter Code