This question has already been answered:

Is it possible to create Navigation Drawer in a separate fragment, if so how? And if not, then how to do it right, just say that the approach with the fragments is more correct.

Reported as a duplicate by participants YurySPb ♦ , pavlofff android Feb 11 '17 at 5:37 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • The left menu should be in actviti. Why shove it into a fragment? - YurySPb ♦
  • I just have just one activity now, and fragments are changing in it, and now there should be a left menu in one fragment, but I don’t need the rest, I wanted to know whether to transfer this fragment to activation, or there is some other way. - Fedia
  • Well, in theory, you can shove the necessary markup into a fragment and it should even work ... But I would advise you to implement it in a separate activity. - Yuriy SPb ♦
  • It was just before it was in activism, I transferred everything into a fragment because they said that it wouldn’t work like that, they say this approach is not correct, but now it turns out that you need to redo it as it was before. - Fedia
  • I'm just already confused what approach is right and who to listen to. Can you hear your professional point of view? - Fedia

2 answers 2

It is impossible. And if it is possible, it is not necessary. I think that you have a little misunderstood what you were told. A good practice is to use NavigationDrawer in one activity, putting any number of fragments into it.

    If a part of the interface should contain NavigationDrawer , and the other is not, then the most correct solution would be to divide the interface into at least two activites, one of which implements NavigationDrawer and hosts fragments that this drover also needs to implement, the second does not implement it and, if necessary, Host fragments that also do not have to implement a drover, but are connected by chains of transitions, or switch to other activites that also do not implement a drover.

    Also, if a drover has to realize only one screen, then the use of fragments is generally doubtful. It is also worth noting that there are solutions with a drover and several screens that do not use fragments.

    At the end, my opinion on how to decide whether you need fragments in general in your application.