Search code examples
androidandroid-fragmentsandroid-activitynavigation-drawerandroid-fragmentactivity

Activity or Fragment with NavigationDrawer


I have 4 modules in an application that are not related to each other. So I previously had created 4 different activities all extending to a base activity that implements the NavigationDrawer. I would like to know if it is better to use fragments over here instead of activity?. I mean, if I make one activity that implements the NavigationDrawer and create 4 fragments for the 4 modules?. Also, what is the difference between Fragment and FragementActivity?


Solution

  • I think one activity that implements the NavigationDrawer and creates 4 fragments for the 4 modules. It's better!

    Activities are designed to represent a single screen of the application, while Fragments are designed to be reusable UI layouts with logic embedded inside of them. According to Google's lectures :Multi-Versioning Android User Interfaces . Fragments makes your code easier to maintain and control.

    what is the difference between Fragment and FragementActivity?

    You can see here: Difference between Fragment And FragmentActivity