5.4.8. fragment_quiz.xml Layout

You’ll typically define a layout for each of your Fragments. For each Fragment layout, you’ll add a layout XML file to your app’s res/layout folder(s) and specify which Fragment class the layout is associated with. Note that you do not need to define a layout for this app’s SettingsFragment because its GUI is auto-generated by the inherited capabilities of class PreferenceFragment.

This section presents the QuizFragment’s layout (fragment_quiz.xml). You’ll define its layout file once in the app’s res/layout folder, because we use the same layout for the QuizFragment on all devices and device orientations. Figure 5.12 shows the QuizFragment’s GUI component names.

Fig. 5.12 | Flag Quiz GUI’s components labeled with ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.