java - Recycler view inside a Custom Compound view -


i need create recyclerview inside custom view. following code:

public class citysinglepagegridview extends linearlayout {     context context ;     view mview ;     recyclerview recyclerview ;     recyclerview.layoutmanager  layoutmanager ;     recyclerview.adapter adapter;    public citysinglepagegridview(context context, attributeset attrs) {     super(context, attrs);     this.context = context ;       layoutinflater inflater;     inflater = (layoutinflater) context             .getsystemservice(context.layout_inflater_service);     mview = inflater.inflate(r.layout.module_city_single_page_gridview,this,true);     recyclerview = (recyclerview) mview.findviewbyid(r.id.cardlist);     recyclerview.sethasfixedsize(true);       layoutmanager =  new linearlayoutmanager(context);     recyclerview.setlayoutmanager(layoutmanager);     adapter = new citycardviewadapter();      recyclerview.setadapter(adapter);       } } 

the problem when run application nothing shows in custom view, when i'm using recyclerview in fragment or activity works fine.

following custom adapter:

public class citycardviewadapter extends recyclerview.adapter<citycardviewadapter.viewholder> { @override public viewholder oncreateviewholder(viewgroup parent, int viewtype) {     view view = layoutinflater.from(parent.getcontext())             .inflate(r.layout.item_card_item_city, parent, false);      viewholder viewholder = new viewholder(view);     return viewholder; }  @override public void onbindviewholder(final viewholder holder, int position) { }    @override public int getitemcount() {     return 5; }  public static class viewholder extends recyclerview.viewholder{     protected textview title;     protected textview desc ;     protected textview distance ;     protected textview likecount ;     protected imageview thumbnail ;     protected imageview ;     protected imageview distance ;      public viewholder(view itemview) {         super(itemview);         title =  (textview) itemview.findviewbyid(r.id.title);         desc = (textview) itemview.findviewbyid(r.id.desc);         distance = (textview) itemview.findviewbyid(r.id.distance);         likecount = (textview) itemview.findviewbyid(r.id.likecount);         thumbnail = (imageview) itemview.findviewbyid(r.id.thumbnail);         = (imageview) itemview.findviewbyid(r.id.like);         distance = (imageview) itemview.findviewbyid(r.id.nav);         }     } } 

i set getitemcount 5 test application.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -