Multiple choice

Which of the following codes will create a tabbed interface?

  1. Android:actionProviderClass=”android.widget.ShareActionProvider”
    
  2. Public void onCreate(Bundle bun1) {
     Super.onCreate(bun1);
     final ActionBar bar = getActionBar();
     bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }
    
  3. Public void onCreate(Bundle bun1) {
     Super.onCreate(bun1);
     final ActionBar bar = getActionBar();
     bar.setNavigationMode(ActionBar.NAVIGATION_TABS);
    }
    
  4. Public void onCreate(Bundle bun1) {
     Super.onCreate(bun1);
     final ActionBar = getActionBar();
     bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }
    
Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

To create a tabbed interface, you have to set the navigation mode for the action bar in the onCreate method of your activity. The code is:

Public void onCreate(Bundle bun1) {
 Super.onCreate(bun1);
 final ActionBar bar = getActionBar();
 bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}