July 2015
Beginner to intermediate
600 pages
18h 59m
English
To host a UI fragment, an activity must:
define a spot in its layout for the fragment’s view
manage the lifecycle of the fragment instance
Figure 7.12 shows the fragment lifecycle. It is similar to the activity lifecycle: it has stopped, paused, and running states, and it has methods you can override to get things done at critical points – many of which correspond to activity lifecycle methods.
Figure 7.12 Fragment lifecycle diagram
The correspondence is important. Because a fragment works on behalf of an activity, its state should reflect the activity’s state. ...
Read now
Unlock full access