1

I have an activity that extends fragmentActivity that has a navigation Drawer, and three different fragments.

Is there a way to make a navigation Drawer that has different buttons inside each of my fragments?

For example when you enter fragment 1 you will see certain buttons in the navigation Drawer, and when you go to fragment 2 you will see different buttons in the navigation Drawer.

Dgotlieb
  • 1,393
  • 2
  • 9
  • 15

1 Answers1

0

You should just define which options are to be displayed in the NavigationDrawer depending on which current Fragment you're on, using a switch statement or if statement.

Check out this link: How to change fragments using Android navigation drawer

Also, from this link https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html

As per the Android Design guide, any drawers positioned to the left/start should always contain content for navigating around the application, whereas any drawers positioned to the right/end should always contain actions to take on the current content. This preserves the same navigation left, actions right structure present in the Action Bar and elsewhere.

So this type of thing seems like it was planned for when the NavigationDrawer was designed.

Ethan
  • 1,206
  • 3
  • 21
  • 39
  • Thank you so much for your quick answer. Because I'm pretty new at that, if it's not too much to ask, will you be able to add a Sample code? Thx again – Dgotlieb Feb 10 '16 at 19:20
  • Check the navigation drawer link, it has several code snippets – Ethan Feb 10 '16 at 21:32
  • I've already manage to create a navigation Drawer in the main activity so it shows in all of the fragments, but what I didn't manage to is changing the buttons in each of them. – Dgotlieb Feb 11 '16 at 05:20
  • You should be able to swap out the text and the action performed in on click via an if-block that relies on the current fragment selections. – Ethan Feb 11 '16 at 16:29