java - Reference a Recyclerview that was in a fragment in Appcompat activity? -


hey have recyclerview , recyclerview adapter shown below. however, recyclerview adapter inflated inside activity extends fragment. time want use in activity extends appcompatactivity, how do that?

  @override public view oncreateview(layoutinflater inflater, viewgroup container,                          bundle savedinstancestate) {     // inflate layout fragment      view view=inflater.inflate(r.layout.fragment_dashboard,container,false);     mrecyclerview=(recyclerview)view.findviewbyid(r.id.id);     mrecyclerview.setlayoutmanager(new linearlayoutmanager(this));     madapterdashboard=new adapterdashboard(this);     mrecyclerview.setadapter(madapterdashboard);     return view; 

just use same code inside oncreate() method of activity

// initialize recycler view mrecyclerview = (recyclerview) findviewbyid(r.id.id); mrecyclerview.setlayoutmanager(new linearlayoutmanager(this)); madapterdashboard=new adapterdashboard(this); mrecyclerview.setadapter(madapterdashboard); 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -