5.3.3. Fragment Lifecycle Methods

Like an Activity, each Fragment has a lifecycle and provides methods that you can override to respond to lifecycle events. In this app, you’ll override:

onCreate—This method (which you’ll override in class SettingsFragment) is called when a Fragment is created. The QuizFragment and SettingsFragment are created when their parent activities’ layouts are inflated, and the DialogFragment that displays the quiz results is created when you complete a quiz.

onCreateView—This method (which you’ll override in class QuizFragment) is called after onCreate to build and return a View containing the Fragment’s GUI. As you’ll see, this method receives a LayoutInflater, which you’ll use to programmatically inflate a Fragment’s GUI from the components specified in a predefined XML layout.

We’ll discuss other Fragment lifecycle methods as we encounter them throughout the book. For the complete lifecycle details, visit:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.67.235