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 ...
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