how to open another menu on click of item on the default menu of navigation drawer

542 Views Asked by At

let me make it simple to explain by images. i have a navigationview which contains a default menu, similar to this.

default menu in navigation view

if i click an item, it should open another menu in the drawer itself.

This is the Menu after selecting an item

I have doing some R&D since past few days but unable to get any idea. as i want to do it myself, i just want some hint to do this.

Thank you in advance.

1

There are 1 best solutions below

0
On BEST ANSWER

You should use the fragment to achieve this

Replace the FrameLayout with your fragment on the click of your item

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/white"
        android:orientation="vertical">

        <FrameLayout
            android:id="@+id/frmContainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

        </FrameLayout>

    </LinearLayout>

</android.support.v4.widget.DrawerLayout>