Perhaps somebody can help me understand this question about the subject. I already made my navigation view, but now I want the same navigation view in my other 2 activities. What I don't understand is how should I properly implement my layouts for the rest of the activities, because trying I ended up practically cloning the first layout. My doubt is exclusively on the building/writing of the layouts for the other activities. Would have comented there, but my reputation does not allow me.
Asked
Active
Viewed 91 times
-3

Guanaco Devs
- 1,822
- 2
- 21
- 38
-
you can use fragments for that pupose – AskNilesh Jun 23 '17 at 05:32
-
I want to use activities, because in the second activity I have a SectionsPagerAdapter – Guanaco Devs Jun 23 '17 at 05:39
-
Link which u have metioned in the question has already answer..You have to use understand the code – Ravindra Kushwaha Jun 23 '17 at 05:46
-
Yep, I know they I have an answer already, but I don't clearly understand it, since I can't comment over there, I posted looking for some light. @Abhishek Tyagi already gave me some. Ty – Guanaco Devs Jun 23 '17 at 06:01
2 Answers
1
Use fragments, make your navigation layout a fragment and place that fragment wherever you need that layout or you can also create a parent activity class in which you implement your navigation layout and extend that activity in rest of your activities.

Abhishek Tyagi
- 143
- 10
-
I did extended my second activity to my Main activity with the Navigation Drawer, but I ended up almost cloning my Main activity for my second activity. Don't want to use fragments because my Main activity is made of 4 fragments and I don't have much experience with fragments. – Guanaco Devs Jun 23 '17 at 05:41
-
1don't extend your main activity, create a base activity class and extend it in both the activities. The base activity can contain all of the common code – Abhishek Tyagi Jun 23 '17 at 05:49
-
Thank you, now you give me some light, I thought when they mentioned BaseActivity, was extending an activity with a NavigationView already implemented not a "BaseActivity" itself. Thank You @Abhishek Tyagi, I'll see what I can do now, with your useful clarification. – Guanaco Devs Jun 23 '17 at 05:59
0
This is the EASIEST and CLEARER implementation for what I wanted to achieve, code might use some optimization, but does what I was looking for after reading several posts in the last three days.

Guanaco Devs
- 1,822
- 2
- 21
- 38