Code example for ActionBar

Methods: addTab

0
            throw new IllegalStateException("CompatTab must have a CompatTabListener");
        } 
 
        // We know tab is a CompatTabHoneycomb instance, so its 
        // native tab object is an ActionBar.Tab. 
        mActionBar.addTab((ActionBar.Tab) tab.getTab());
    } 
 
    @Override 
    protected void onSaveInstanceState(Bundle outState) {
        int position = mActionBar.getSelectedTab().getPosition();
        outState.putInt("tab_position", position);
    } 
 
    @Override 
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        int position = savedInstanceState.getInt("tab_position");
        mActionBar.setSelectedNavigationItem(position);
    } 
}