Introducing Fragments
You can ensure that your app is flexible by moving the app’s UI management from the activity to one or more fragments.
A fragment is a controller object that an activity can deputize to perform tasks. Most commonly, the task is managing a UI. The UI can be an entire screen or just one part of the screen.
A fragment managing a UI is known as a UI fragment. A UI fragment has a view of its own that is inflated from a layout file. The fragment’s view contains the interesting UI elements that the user wants to see and interact with.
Instead of containing the UI, the activity’s view can hold a container for the fragment. The fragment’s view is inserted into the container once it is inflated. In this chapter, the ...
Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.