I have a problem...I am developing an app in android studio.In the meantime,there is already a navigation drawer in it.But the problem is, it only appears in the home screen.When it goes to another screen, the navigation drawer is not shown. I am new to android studio but i know some of Java languages.Can anyone help me with providing anything that would help me make the navigation drawer show in all of slides and pages in my app.

- 93,459
- 16
- 209
- 274

- 21
- 3
-
Try using fragments instead of activity. Refer [this link](http://stackoverflow.com/questions/24006181/android-how-to-change-fragments-in-the-navigation-drawer) – user3678528 Sep 01 '16 at 04:21
-
Thank you for your answer,but my app already has a navigation drawer.and the fragments are all in one layout...how do i copy paste that navigation drawer codes and paste it in other activity to show in it without using fragments??how do i do it??which code should I copy and paste, and where should I do it? – L.King Sep 09 '16 at 01:24
2 Answers
from docs
The navigation drawer is a panel that displays the app’s main navigation options on the left edge of the screen. It is hidden most of the time, but is revealed when the user swipes a finger from the left edge of the screen or, while at the top level of the app, the user touches the app icon in the action bar.
for achieve what you asked you have to use Fragments
Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).
see this examples for more details
1. Navigation Drawer - android hive
Refer this answer also
-
Thank you for your answer,but my app already has a navigation drawer.and the fragments are all in one layout...how do i copy paste that navigation drawer codes and paste it in other activity to show in it without using fragments??how do i do it??which code should I copy and paste, and where should I do it? – L.King Sep 09 '16 at 01:23
You have to add fragments in that activity where the navigation drawer exist. Whenver the user will click on the option in the navigation drawer the view should be changed by replacing with the required fragment.So by using the fragments user will stay on the same activity but just the views will be changed in that activity.
you can refer to the fragments documentation provided by android developers. https://developer.android.com/guide/components/fragments.html

- 427
- 3
- 17
-
Thank you for your answer,but my app already has a navigation drawer.and the fragments are all in one layout...how do i copy paste that navigation drawer codes and paste it in other activity to show in it without using fragments??how do i do it??which code should I copy and paste, and where should I do it? – L.King Sep 09 '16 at 01:24