I am a beginner android developer, and right now I'm learning about fragments in android, and so and as I read that :
A fragment is just a part of an activity. You can have a fragment that takes up part of a screen or a whole screen. Or you can show multiple fragments at the same time to make up a whole screen. Within an activity, you can also swap out different fragments with each other. (You can also have invisible fragments as well, that do some work related to the activity, but we won’t cover those in this course.)
Fragments were introduced in Android when we started building for larger screen devices like tablets. Let me show you an example.
In the master/detail pattern, a list fragment is on the left side of the screen, while the detail fragment on the right swaps out depending on the list item selected.
So, I'm asking what's the utility of fragments apart from adapting to larger screens? Thanks !!
You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).