Paraskevas Ntsounos
Paraskevas Ntsounos

Reputation: 1777

Collapsible item in navigation drawer with expandablelistview implementation

I'm using android NavigationView I want after location touched from user expand something like a submenu and display the current location of user. Location is not my problem, my real problem is that I don't know how to implement ExpandableListView inside drawer for this simple example. Maybe you could suggest me an informative step by step tutorial for this one since I'm new android developer and I want to learn more.

Here is my menu.xml

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

<group android:checkableBehavior="single">
    <item android:id="@+id/location" android:icon="@drawable/mylocation" android:title="@string/My_Location"  android:animateLayoutChanges="true"/>
</group>

<item android:title="@string/action_settings">
    <menu>
        <group android:checkableBehavior="single">
            <item android:id="@+id/profile" android:icon="@drawable/settings"
                android:title="@string/Edit_Profile" android:animateLayoutChanges="true" />
            <item android:id="@+id/logout" android:icon="@drawable/logout"
                android:title="@string/Log_Out"  android:animateLayoutChanges="true"/>
        </group>
    </menu>
</item>

   @SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

   if (id == R.id.location) { 
        //todo 
   }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

Upvotes: 2

Views: 1627

Answers (0)

Related Questions