Reputation: 85
I'm writing an android app which uses a drawer navigation in which the user can go to different activities. Inside the activities, the user can launch a new child-activity and can come back to the original one via up navigation in the AppBar.
Until now, I normally launched the new activities via an intent after they were chosen in the drawer menu. Then inside the chosen activity I created a new AppBar in onCreate();
However, I want to use the same Drawer for all Activities because I want the current activity, to be shaded in the menu and I also don't want to set up a new AppBar in many of the activites.
I've read that the common way to this, is to make a BaseActivity and a base_layout, which hosts the AppBar and the Activities as a Fragment. However, that's also not really suitable for me, since I can't declare styles in the manifest and upward navigation doesn't work.
How would you go about the problem?
Upvotes: 0
Views: 734
Reputation: 1464
If u want to make a navigation drawer that works for all fragment then
make a navigation drawer inside the main activity(This will work as a parent activity) and u can open fragment from that navigation drawer
Here is the tutorial
https://www.journaldev.com/9958/android-navigation-drawer-example-tutorial
Upvotes: 1