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

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

Introduction

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

Prototype

int NAVIGATION_MODE_TABS

To view the source code for android.support.v4.app ActionBar NAVIGATION_MODE_TABS.

Click Source Link

Document

Tab navigation mode.

Usage

From source file:com.actionbarsherlock.sample.demos.app.ActionBarTabsPager.java

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

    setContentView(R.layout.actionbar_tabs_pager);
    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab tab1 = getSupportActionBar().newTab().setText("Tab 1");
    ActionBar.Tab tab2 = getSupportActionBar().newTab().setText("Tab 2");
    ActionBar.Tab tab3 = getSupportActionBar().newTab().setText("Tab 3");
    ActionBar.Tab tab4 = getSupportActionBar().newTab().setText("Tab 4");

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(tab1, FragmentStackSupport.CountingFragment.class);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ECLAIR) {
        mTabsAdapter.addTab(tab2, FragmentStackSupport.CountingFragment.class);
        mTabsAdapter.addTab(tab3, FragmentStackSupport.CountingFragment.class);
        mTabsAdapter.addTab(tab4, FragmentStackSupport.CountingFragment.class);
    } else {/* w  w w .jav  a 2s . c  o m*/
        mTabsAdapter.addTab(tab2, LoaderCursorSupport.CursorLoaderListFragment.class);
        mTabsAdapter.addTab(tab3, LoaderCustomSupport.AppListFragment.class);
        mTabsAdapter.addTab(tab4, LoaderThrottleSupport.ThrottledLoaderListFragment.class);
    }

    if (savedInstanceState != null) {
        getSupportActionBar().setSelectedNavigationItem(savedInstanceState.getInt("index"));
    }
}

From source file:com.abcvoipsip.ui.prefs.Codecs.java

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

    setContentView(R.layout.codecs_pager);

    final ActionBar ab = getSupportActionBar();
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ab.setDisplayShowHomeEnabled(true);//from ww  w . j  av  a 2  s. c  om
    ab.setDisplayShowTitleEnabled(true);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    TabsAdapter tabAdapter = new TabsAdapter(this, ab, mViewPager);

    Tab audioNb = ab.newTab().setText(R.string.narrow_band).setIcon(R.drawable.ic_prefs_media);
    Tab audioWb = ab.newTab().setText(R.string.wide_band).setIcon(R.drawable.ic_prefs_media);
    Tab videoNb = ab.newTab().setText(R.string.narrow_band).setIcon(R.drawable.ic_prefs_media_video);
    Tab videoWb = ab.newTab().setText(R.string.wide_band).setIcon(R.drawable.ic_prefs_media_video);

    tabAdapter.addTab(audioWb, CodecsFragment.class);
    tabAdapter.addTab(audioNb, CodecsFragment.class);
    tabAdapter.addTab(videoWb, CodecsFragment.class);
    tabAdapter.addTab(videoNb, CodecsFragment.class);
}

From source file:org.kevoree.platform.android.boot.view.ManagerUI.java

public ManagerUI(FragmentActivity context) {
    this.ctx = context;
    ctx.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}

From source file:org.kevoree.platform.android.boot.view.ManagerUI.java

/**
 * this method is charge of restoring views during a rotation of the screen
 *///from w  w  w .j  a v a  2  s  .c  o m
public void restoreViews(FragmentActivity newctx) {
    if (ctx.getSupportActionBar().getTabAt(selectedTab) == null) {
        selectedTab = ktab;
    }
    ctx.getSupportActionBar().removeAllTabs();
    newctx.getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ctx = newctx;
    LinkedList<ActionBar.Tab> backup = new LinkedList<ActionBar.Tab>();
    backup.addAll(tabs);
    tabs.clear();
    for (ActionBar.Tab tab : backup) {
        Log.i(TAG, "Restore " + tab.getText());
        // if exist remove parent
        View contentView = (View) tab.getTag();
        if (contentView.getParent() != null) {
            ((ViewGroup) contentView.getParent()).removeView(contentView);
        }
        LinearLayout tabLayout = (LinearLayout) contentView;
        int childcount = tabLayout.getChildCount();
        for (int i = 0; i < childcount; i++) {
            View v = tabLayout.getChildAt(i);
            if (v != null) {
                // remove link to linearlayout
                if (v.getParent() != null) {
                    ((ViewGroup) v.getParent()).removeView(v);
                }
                addToGroup(tab.getText().toString(), v);
            }
        }
    }
    try {
        ctx.getSupportActionBar().setSelectedNavigationItem(selectedTab);
    } catch (Exception e) {
        // ignore
    }
}

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);
    }//w  ww  . j  av  a  2s  . c om

    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));
    }
}

From source file:com.flipzu.flipzu.Listings.java

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

    /* restore settings object */
    settings = getSharedPreferences(PREFS_NAME, 0);

    /* init Google Analytics tracker */
    initGATracker();/*from  w  ww. j  av a  2 s. c  o  m*/

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.actionbar_tabs_pager);

    setProgressBarIndeterminateVisibility(Boolean.FALSE);

    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.ab_background));

    ActionBar.Tab tab1 = getSupportActionBar().newTab().setIcon(R.drawable.all);
    ActionBar.Tab tab2 = getSupportActionBar().newTab().setIcon(R.drawable.friends);
    ActionBar.Tab tab3 = getSupportActionBar().newTab().setIcon(R.drawable.me);
    ActionBar.Tab tab4 = getSupportActionBar().newTab().setIcon(R.drawable.hot);
    ActionBar.Tab tab5 = getSupportActionBar().newTab().setIcon(R.drawable.search);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(tab1, ListingsFragmentAll.class);
    mTabsAdapter.addTab(tab2, ListingsFragmentFriends.class);
    mTabsAdapter.addTab(tab3, ListingsFragmentProfile.class);
    mTabsAdapter.addTab(tab4, ListingsFragmentHottest.class);
    mTabsAdapter.addTab(tab5, SearchFragment.class);

    if (savedInstanceState != null) {
        getSupportActionBar().setSelectedNavigationItem(savedInstanceState.getInt("index"));
    }
    AppRater.app_launched(this);
}

From source file:org.androidui.app.ActionBarImpl.java

@Override
public int getNavigationItemCount() {
    switch (mActionView.getNavigationMode()) {
    default:// w  w w .j av  a  2s.  c o  m
    case ActionBar.NAVIGATION_MODE_STANDARD:
        return 0;

    case ActionBar.NAVIGATION_MODE_LIST:
        SpinnerAdapter dropdownAdapter = mActionView.getDropdownAdapter();
        return (dropdownAdapter != null) ? dropdownAdapter.getCount() : 0;

    case ActionBar.NAVIGATION_MODE_TABS:
        if (mActionView.getSelectedTab() == null) {
            return -1;
        }
        return mActionView.getTabCount();
    }
}

From source file:org.androidui.app.ActionBarImpl.java

@Override
public int getSelectedNavigationIndex() {
    switch (mActionView.getNavigationMode()) {
    default:// w  ww. j a  v  a  2  s  . c  om
    case ActionBar.NAVIGATION_MODE_STANDARD:
        return -1;

    case ActionBar.NAVIGATION_MODE_LIST:
        return mActionView.getDropdownSelectedPosition();

    case ActionBar.NAVIGATION_MODE_TABS:
        return mActionView.getSelectedTab().getPosition();
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    //prefWrapper = new PreferencesWrapper(this);
    prefProviderWrapper = new PreferencesProviderWrapper(this);

    /*/*  w ww  . j ava2 s .c  om*/
     * Resources r; try { r =
     * getPackageManager().getResourcesForApplication("com.etatgere"); int
     * rThemeId = r.getIdentifier("com.etatgere:style/LightTheme", null,
     * null); Log.e(THIS_FILE, "Remote theme " + rThemeId); Theme t =
     * r.newTheme(); t.applyStyle(rThemeId, false); //getTheme().setTo(t); }
     * catch (NameNotFoundException e) { Log.e(THIS_FILE,
     * "Not found app etatgere"); }
     */
    if (USE_LIGHT_THEME) {
        setTheme(R.style.LightTheme_noTopActionBar);
    }

    super.onCreate(savedInstanceState);

    setContentView(R.layout.sip_home);

    final ActionBar ab = getSupportActionBar();
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // showAbTitle = Compatibility.hasPermanentMenuKey

    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);

    Tab dialerTab = ab.newTab()
            // .setText(R.string.dial_tab_name_text)
            .setIcon(R.drawable.ic_ab_dialer_holo_dark);
    Tab callLogTab = ab.newTab()
            // .setText(R.string.calllog_tab_name_text)
            .setIcon(R.drawable.ic_ab_history_holo_dark);

    Tab favoritesTab = ab.newTab()
            // .setText(R.string.messages_tab_name_text)
            .setIcon(R.drawable.ic_ab_favourites_holo_dark);

    Tab messagingTab = null;
    if (CustomDistribution.supportMessaging()) {
        messagingTab = ab.newTab()
                // .setText(R.string.messages_tab_name_text)
                .setIcon(R.drawable.ic_ab_text_holo_dark);
    }

    mDualPane = getResources().getBoolean(R.bool.use_dual_panes);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager);
    mTabsAdapter.addTab(dialerTab, DialerFragment.class);
    mTabsAdapter.addTab(callLogTab, CallLogListFragment.class);
    mTabsAdapter.addTab(favoritesTab, FavListFragment.class);
    if (messagingTab != null) {
        mTabsAdapter.addTab(messagingTab, ConversationsListFragment.class);
    }

    hasTriedOnceActivateAcc = false;

    if (!prefProviderWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    selectTabWithAction(getIntent());
    Log.setLogLevel(prefProviderWrapper.getLogLevel());

    // Async check
    asyncSanityCheker = new Thread() {
        public void run() {
            asyncSanityCheck();
        };
    };
    asyncSanityCheker.start();
}

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

private void showTabsNav() {
    ActionBar ab = getSupportActionBar();
    if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_TABS) {
        ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }//  w w w .  ja  v a2s  .c  o m
}