March 2016
Intermediate to advanced
428 pages
9h 2m
English
Defining a Fragment in the layout, as we did in the previous recipe, is known as a static Fragment and cannot be changed during runtime. Rather than using the <fragment> element, we will create a container to hold the Fragment, then create the Fragment dynamically in the Activity's onCreate() method.
The FragmentManager provides the APIs for adding, removing, and changing Fragments during runtime using a FragmentTransaction. A Fragment transaction consists of:
This recipe will demonstrate the FragmentManager by adding and removing Fragments during runtime.
Create a new project in Android Studio and call it: ...