-3

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.

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

2 Answers2

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.

  • 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
  • 1
    don'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