Imagine Chrome redrew all your tabs and bookmarks each time you changed the current page, or imagine if you dumped out and put back everything in your pencil case each time you needed an eraser. There are clearly some actions in those two scenarios that do not need changing, so why go through the hassle of taking away something before putting it all back?
That’s often the case in many apps: there are parts of a UI that doesn't need any change from screen to screen. Android’s solution to this problem is fittingly called a Fragment, which allows developers to change sections of the app without changing the activity.
In this chapter, we will be going into details about the difference between a
Activity, and the basic implementation of a
- What are Fragments?
- Lifecycle of a Fragment
- Integrating a Fragment into an Activity
- Sharing Data Between Fragments