Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Introducing Fragments
You can make your app’s UI more flexible by moving UI management from the activity to one or more fragments.
Similar to how you have used your activities so far, a Fragment has a view of its own, often defined in a separate 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 acts as a container for the fragment. The fragment’s view is inserted into the container once it is initialized. In this chapter, the activity will host a single fragment, but an activity can have multiple containers in its view for different fragments.
Fragments are designed to hold reusable chunks of the UI. You can use the fragment ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access