0

I found nice tutorial that teach how to add both Left and Right Navigation Drawers in Android App.

https://updateunlimited.blogspot.com/2015/12/double-sided-nav-drawers.html

Everything works in empty project with just one main activity. But I want to use this solution in second activity. I have created file activity_right_drawer.xml in menu directory. I have added second NavigationView in second_activity.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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_kategorie"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    />

<android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:fitsSystemWindows="true"
    android:background="#2A3E6B"
    app:itemTextColor="#eee"
    app:itemIconTint="#eee"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_main_drawer" />



<android.support.design.widget.NavigationView
    android:id="@+id/nav_right_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:fitsSystemWindows="true"
    app:headerLayout="@layout/nav_header_main"
    app:menu="@menu/activity_right_drawer" />


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

But the problem raise with file main.xml Tutorial says to add item into main.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_openRight"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        android:icon="@drawable/ic_open_right"
        app:showAsAction="always" />
</menu>

This file is only for MainActivity not for secondActivity. How can I create file like main.xml for secondActivity and tell me that second_main.xml is file for secondActivity

Adding FrameLayout like Two Navigation Drawer on same Activity doesnt help, otherwise i need to use NavigationView not ListView

Agnes
  • 77
  • 2
  • 10
  • May be you have written this line getMenuInflater().inflate(R.menu.main, menu); this indicated inflating main.xml. change this to second_main in second activity – Vidhi Dave Dec 22 '17 at 09:28
  • Possible duplicate of [Two Navigation Drawer on same Activity](https://stackoverflow.com/questions/29921274/two-navigation-drawer-on-same-activity) – AskNilesh Dec 22 '17 at 09:31
  • Adding FrameLayout doesnt not solved my problem – Agnes Dec 22 '17 at 09:54
  • Yes i have getMenuInflater().inflate(R.menu.main, menu); but why my second activity doesnt see that in this file is added item, only first activity show right icon second activity doest show it – Agnes Dec 22 '17 at 10:08

0 Answers0