简体   繁体   中英

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

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM