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
Post a Comment