Good day. I’ve copied on stackoverflow a link to the NavigationDrawer menu, read it and attached it to my application. In the code, when I clicked on the menu item, I found the code (at the very bottom of the page is the full MainActivity code) and this is what puzzled:

case 0: fragment = new HomeFragment(); break; case 1: fragment = new FindPeopleFragment(); break; 

continued in the same vein. So, when you click on an item, a fragment of the corresponding list item is displayed on the application screen. What then will be the structure of the program? Those. Are there fragments everywhere? Is it possible to somehow do without these fragments, so that when you click on a list item, create a new Activity with the necessary content?

    1 answer 1

    Is it possible to somehow do without these fragments, so that when you click on a list item, create a new Activity with the necessary content?

    Ummm, why? NavigationDrawer assumes the use of fragments, without them, it will not achieve that speed of work, and it’s more convenient to order

    • Yes, and it is more convenient to the order And if I have sections, pieces of 15, in each there are x categories. Would it be convenient to create 15 * x fragments and as many layouts? - PhoEn-X
    • one
      it is definitely more convenient ─ the side menu is in itself a fragment, you can hang on it any listeners and process as you like, although using activity will be pretty perverted. Nobody forces you to create all 15 * x fragments at a time, if all the fragments of a different structure, you will still have to create different markup, the activity will not solve it) If the fragments have the same structure, but with different data, simply transfer this data there. - gadfil
    • I will add from myself. The fragments are more convenient from the Activity even if they do not need to be written in the Manifesto. The rest of their life cycle is very similar. So it's easier to make a parent Activity, on which fragments will be displayed and work with them. - Lucky_spirit
    • + to all the joys of fragments, it is possible to prohibit recreating an Activity when turning and recreating only a fragment, if the logic in the Activity then it simplifies the work, a trifle is pleasant, and works faster - gadfil