Code example for ActionBar

Methods: addTabnewTab

0
    public void setListener(Listener listener) {
        mListener = listener;
    } 
 
    private void addTab(int expectedTabIndex, int icon, int description) {
        final Tab tab = mActionBar.newTab();
        tab.setTabListener(mTabListener);
        if (mShowTabsAsText) {
            tab.setText(description);
        } else { 
            tab.setIcon(icon);
            tab.setContentDescription(description);
        } 
        mActionBar.addTab(tab);
        if (expectedTabIndex != tab.getPosition()) {
            throw new IllegalStateException("Tabs must be created in the right order");
        } 
    } 
 
    private class MyTabListener implements ActionBar.TabListener {
Contextual code suggestions in your IDE  Get Codota for Java