5.8. SettingsActivity Class

Class SettingsActivity (Fig. 5.36) hosts the SettingsFragment when the app is running in portrait orientation. To create this class, right click the package (com.deitel.flagquiz) and select New > Class to display the New Java Class dialog. Set the new class’s Name to SettingsActivity, set its Superclass to android.app.Activity and click Finish.

 1   // SettingsActivity.java 2   // Activity to display SettingsFragment on a phone 3   package com.deitel.flagquiz; 4  5   import android.app.Activity; 6   import android.os.Bundle; 7  8   public class SettingsActivity extends Activity 9   {10      // use FragmentManager to display SettingsFragment11      @Override12      protected void onCreate(Bundle ...

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.