Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activities or Fragments in NavigationView?

I have a NavigationView used as a slide-in menu. Each of that menu items is a use case itself, therefore I tend to using activities containing different fragments.

But nearly every example of NavigationView/NavigationDrawer uses fragments, so I don't know what to use here.

I thought different use cases should be "encapsulated" in own activities, therefore I don't really understand why Navigation[View/Drawer] uses fragments. And that leads me to my question: for a Navigation[View/Drawer] containing completely separate use cases - should I link to activities or fragments?

like image 466
swalkner Avatar asked Aug 18 '15 08:08

swalkner


1 Answers

I posted a similar question

I have created around 4-5 apps with mid-big size project. I used Fragments for Navigation Menu clicks and had to manage lots of Lifecycle events and Memory Leaks and shit stuff. The Performance degrades and app becomes slow.

Then in one of the app I Used Activities for each Navigation menu clicks, treating it separate Entity/Module. This Activity would then use fragments if they had child views.

Doing so I had a great app, less trouble and I could concentrate on Business Logic rather than maintaining fragments.

Although Google recommends Fragments, But I never liked them, they always put me in trouble and handling them is a mess.

In my current Project I have created a BaseActivity implementing Navigation and all the other Activity extend it.

like image 103
Rinav Avatar answered Oct 23 '22 00:10

Rinav