json - One activity using with two adapter in android -


im using recyclerview , expandablelistview in activity, both load data 1 layout, have tried use activity call 1 adapter seem unsuccess.

this activity (use 2 adapters):

public class detaillistcaractivitydemo extends appcompatactivity {   private recyclerview mrecyclerview, exrecyclerview;   private gridlayoutmanager mlayoutmanager;   private recycleradapter madapter;   private expandablelistadapter exadapter;   private context context;  private arraylist<gettersetter> feeditemlist; // private list<item> itemslistdata;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_detail_list_car_demo);      toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);     getsupportactionbar().setdisplayhomeasupenabled(true);      collapsingtoolbarlayout collapsingtoolbar = (collapsingtoolbarlayout) findviewbyid(r.id.collapsing_toolbar);     collapsingtoolbar.settitle("honda crv test");      //find recyclerview layout     mrecyclerview = (recyclerview) findviewbyid(r.id.recyclerview);     exrecyclerview = (recyclerview) findviewbyid(r.id.recyclerview);      mrecyclerview.sethasfixedsize(true);      exrecyclerview.setlayoutmanager(new linearlayoutmanager(this, linearlayoutmanager.vertical, false));      // recyclerview set layoutmanager     mlayoutmanager = new gridlayoutmanager(this,3);     mlayoutmanager.setspansizelookup(new gridlayoutmanager.spansizelookup() {         @override         public int getspansize(int position) {             return (3 - position % 3);         }     });     // recyclerview.layoutmanager lm = new gridlayoutmanager(this,2);      mrecyclerview.setlayoutmanager(mlayoutmanager);      //adding data arraylist     feeditemlist = new arraylist<gettersetter>();     (int = 0; < 7; i++) {         gettersetter gettersetter = new gettersetter();         feeditemlist.add(gettersetter);     }      //recyclerview adapter     madapter = new recycleradapter(detaillistcaractivitydemo.this, feeditemlist);     //set adpater recyclerview       list<expandablelistadapter.item> data = new arraylist<>();      data.add(new expandablelistadapter.item(expandablelistadapter.header, "fruits"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "apple"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "orange"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "banana"));     data.add(new expandablelistadapter.item(expandablelistadapter.header, "cars"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "audi"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "aston martin"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "bmw"));     data.add(new expandablelistadapter.item(expandablelistadapter.child, "cadillac"));      expandablelistadapter.item places = new expandablelistadapter.item(expandablelistadapter.header, "places");     places.invisiblechildren = new arraylist<>();     places.invisiblechildren.add(new expandablelistadapter.item(expandablelistadapter.child, "kerala"));     places.invisiblechildren.add(new expandablelistadapter.item(expandablelistadapter.child, "tamil nadu"));     places.invisiblechildren.add(new expandablelistadapter.item(expandablelistadapter.child, "karnataka"));     places.invisiblechildren.add(new expandablelistadapter.item(expandablelistadapter.child, "maharashtra"));      data.add(places);      exrecyclerview.setadapter(new expandablelistadapter(data));      mrecyclerview.setadapter(madapter);   }  } 

my layout:

<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true">  <!-- <android.support.v7.widget.recyclerview     android:id="@+id/cardlist"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> -->  <android.support.v7.widget.recyclerview     xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/recyclerview"     android:layout_width="match_parent"     android:layout_height="match_parent"     app:layout_behavior="@string/appbar_scrolling_view_behavior"/>   <android.support.design.widget.appbarlayout     android:id="@+id/appbar"     android:layout_width="match_parent"     android:layout_height="192dp"     android:fitssystemwindows="true"     android:theme="@style/themeoverlay.appcompat.dark.actionbar">      <android.support.design.widget.collapsingtoolbarlayout         android:id="@+id/collapsing_toolbar"         android:layout_width="match_parent"         android:layout_height="match_parent"         android:fitssystemwindows="true"         app:contentscrim="?attr/colorprimary"         app:layout_scrollflags="scroll|exituntilcollapsed">          <imageview             android:id="@+id/header"             android:layout_width="match_parent"             android:layout_height="match_parent"             android:background="@drawable/mercedes"             android:contentdescription="@string/paralax"             android:fitssystemwindows="true"             android:scaletype="centercrop"             app:layout_collapsemode="parallax" />          <android.support.v7.widget.toolbar             android:id="@+id/toolbar"             android:layout_width="match_parent"             android:layout_height="?attr/actionbarsize"             app:layout_collapsemode="pin"             app:popuptheme="@style/themeoverlay.appcompat.light" />      </android.support.design.widget.collapsingtoolbarlayout>  </android.support.design.widget.appbarlayout>  <android.support.design.widget.floatingactionbutton     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_margin="10dp"     app:layout_anchor="@+id/appbar"     app:layout_anchorgravity="bottom|right|end" /> 

i want ask can devide 2 adapter , load data 1 layout ?


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -