Code example for ActionBar

Methods: addTab, newTab, setNavigationMode

0
  @Override 
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
 
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
 
    ActionBar.Tab tab1 = actionBar.newTab();
    tab1.setText("Tab1");
    tab1.setTabListener(new TabListener<Tab1Fragment>(this, "tab1", Tab1Fragment.class));
    actionBar.addTab(tab1);
 
    ActionBar.Tab tab2 = actionBar.newTab();
    tab2.setText("Tab2");
    tab2.setTabListener(new TabListener<Tab2Fragment>(this, "tab2", Tab2Fragment.class));
    actionBar.addTab(tab2);
  } 
 
  @Override 
  public void onItemSelected(String id) {
    boolean mTwoPane = findViewById(R.id.item_detail_container) != null;