Example usage for android.support.v4.app ActionBar getTabAt

List of usage examples for android.support.v4.app ActionBar getTabAt

Introduction

In this page you can find the example usage for android.support.v4.app ActionBar getTabAt.

Prototype

public abstract ActionBar.Tab getTabAt(int index);

Source Link

Document

Returns the tab at the specified index.

Usage

From source file:com.abcvoipsip.ui.SipHome.java

private void selectTabWithAction(Intent intent) {
    if (intent != null) {
        String callAction = intent.getAction();
        if (!TextUtils.isEmpty(callAction)) {
            ActionBar ab = getSupportActionBar();
            Tab toSelectTab = null;/*from w w w. j av  a 2 s .  c o  m*/
            if (callAction.equalsIgnoreCase(SipManager.ACTION_SIP_DIALER)) {
                toSelectTab = ab.getTabAt(TAB_INDEX_DIALER);
            } else if (callAction.equalsIgnoreCase(SipManager.ACTION_SIP_CALLLOG)) {
                toSelectTab = ab.getTabAt(TAB_INDEX_CALL_LOG);
            } else if (callAction.equalsIgnoreCase(SipManager.ACTION_SIP_MESSAGES)) {
                toSelectTab = ab.getTabAt(TAB_INDEX_MESSAGES);
            }
            if (toSelectTab != null) {
                ab.selectTab(toSelectTab);
            }
        }
    }
}

From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) {
        mThemeId = savedInstanceState.getInt("theme");
        this.setTheme(mThemeId);
    }/*  ww  w. j a  v  a 2s .  c o  m*/

    setContentView(R.layout.main);

    Directory.initializeDirectory();

    ActionBar bar = getSupportActionBar();

    int i;
    for (i = 0; i < Directory.getCategoryCount(); i++) {
        bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName()).setTabListener(this));
    }

    mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);

    bar.setCustomView(mActionBarView);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(true);

    // If category is not saved to the savedInstanceState,
    // 0 is returned by default.
    if (savedInstanceState != null) {
        int category = savedInstanceState.getInt("category");
        bar.selectTab(bar.getTabAt(category));
    }
}