java - How can I create sections on my app? -


i want improve new app have question you. how can make sections in app, in navigation drawer?

there's photo if don't understand what's in mind. photo google play

there's activity_main_drawer.xml

<?xml version="1.0" encoding="utf-8"?> 

<group android:checkablebehavior="single">     <item         android:id="@+id/nav_pagrindinis"         android:icon="@drawable/ic_menu_pagrindinis"         android:title="pagrindinis" />     <item         android:id="@+id/nav_soctinklai"         android:icon="@drawable/ic_menu_soctinklai"         android:title="gimnazijos socialiniai tinklai" />     <item         android:id="@+id/nav_dienynas"         android:icon="@drawable/ic_menu_dienynas"         android:title="el. dienynas" />     <item         android:id="@+id/nav_naudingosnuor"         android:icon="@drawable/ic_menu_naudingosnuor"         android:title="naudingos nuorodos"/>     <item         android:id="@+id/nav_kontaktai"         android:icon="@drawable/ic_menu_kontaktai"         android:title="kontaktinÄ— informacija" /> </group> 

and there's excerpt mainactivity.java

@override public boolean onnavigationitemselected(menuitem item) {     // handle navigation view item clicks here.     int id = item.getitemid();      if (id == r.id.nav_pagrindinis) {         //set fragment         pagrindinisfragment fragment = new pagrindinisfragment();         android.support.v4.app.fragmenttransaction fragmenttransaction =                 getsupportfragmentmanager().begintransaction();         fragmenttransaction.replace(r.id.fragment_container, fragment);         fragmenttransaction.commit();         // handle camera action     } else if (id == r.id.nav_soctinklai) {         //set fragment         soctinklaifragment fragment = new soctinklaifragment();         android.support.v4.app.fragmenttransaction fragmenttransaction =                 getsupportfragmentmanager().begintransaction();         fragmenttransaction.replace(r.id.fragment_container, fragment);         fragmenttransaction.commit();      } else if (id == r.id.nav_dienynas) {          intent = new intent(intent.action_view);         i.setdata(uri.parse("https://sistema.tamo.lt"));         startactivity(i);      } else if (id == r.id.nav_naudingosnuor) {      } else if (id == r.id.nav_kontaktai) {          kontaktaifragment fragment = new kontaktaifragment();         android.support.v4.app.fragmenttransaction fragmenttransaction =                 getsupportfragmentmanager().begintransaction();         fragmenttransaction.replace(r.id.fragment_container, fragment);         fragmenttransaction.commit();     }      drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     drawer.closedrawer(gravitycompat.start);     return true; } 

i want make section in place. , if press on it, opens more sections in navigation drawer.

android:id="@+id/nav_naudingosnuor" 

there available libs try 1 that: https://github.com/prashamtrivedi/drawerlayouttest

otherwise need create own expandable list view.


Comments