4.8 SettingsActivity Class

Class SettingsActivity (Fig. 4.43) hosts the SettingsActivityFragment when the app is running in portrait orientation. Overridden method onCreate (lines 11–18) calls method setContentView to inflate the GUI defined by activity_settings.xml (represented by the resource R.layout.activity_settings), then displays the Toolbar defined in SettingsActivity’s layout. Line 17 displays on the app bar an up button that the user can touch to return to the parent MainActivity. The IDE added this line when you added the SettingsActivity to the project and specified its hierarchical parent (Section 4.4.12). We removed from the class the remaining autogenerated code that’s not used in this app. You can also remove the unused menu ...

Get Android How to Program, 3/e 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.