Example usage for android.app ActionBar NAVIGATION_MODE_TABS

List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS

Introduction

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

Prototype

int NAVIGATION_MODE_TABS

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

Click Source Link

Document

Tab navigation mode.

Usage

From source file:com.michellgaby.advsettings.DeviceSettings.java

@TargetApi(11)
@Override/*from ww w .  j a v a 2  s. c  om*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.viewPager);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);

    // Remove title and icon
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.general_settings_title), GeneralSettings.class, null);
    /**
     * mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_mdnie_title),
     * mDNIeFragmentActivity.class, null); mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_sensors_title),
     * SensorsFragmentActivity.class, null);
     */

    mTabsAdapter.addTab(bar.newTab().setText(R.string.system_settings_title), SystemSettings.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.evervolv.toolbox2.Toolbox.java

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

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//from w w w.ja v a2s .  c  o m
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayHomeAsUpEnabled(true);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.interface_title), Interface.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.performance_title), Performance.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.updates_title), Updates.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.dirtyunicorns.hfm.MainActivity.java

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

    // Set up the ViewPager with the sections adapter.
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//w w w . j  a v  a 2 s .co  m
    setContentView(mViewPager);
    ActionBar actionbar = getActionBar();
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDisplayShowTitleEnabled(false);
    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.title_section1), mainFragment.class, null);
    //mTabsAdapter.addTab(actionbar.newTab().setText(R.string.title_section2),customFragment.class, null);

}

From source file:com.Candy.center.CandyCenter.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.slim_center);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from   ww w  .jav  a 2 s  . co m
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.jauker.badgeview.example.TabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tab);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from w w w  .j av  a  2  s  . c  o  m
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        Tab tab = actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this);
        actionBar.addTab(tab);
    }
}

From source file:com.example.android.supportv13.app.ActionBarTabsPager.java

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

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);/*from   w  ww .  j a va  2 s.c  o  m*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:in.suraj.timetableswipe.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // setup action bar

    actionBar = getActionBar();/*from ww w .  java  2s . c om*/
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAdapter);

    for (String tab_name : tabs) {
        actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}

From source file:com.vandalsoftware.filter.PhotoPagerActivity.java

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

    final ViewPager viewPager = new ViewPager(this);
    viewPager.setId(R.id.pager);//from   w  w  w .  j av a 2  s . c  om
    viewPager.setPageMargin((int) (getResources().getDisplayMetrics().density * 10));
    setContentView(viewPager);
    setTitle(R.string.app_name);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    final TabsAdapter tabsAdapter = new TabsAdapter(this, viewPager);
    Bundle bundle;

    bundle = Bundle.EMPTY;
    tabsAdapter.addTab(bar.newTab().setText(R.string.no_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_BW);
    tabsAdapter.addTab(bar.newTab().setText(R.string.bw_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_CHILL);
    tabsAdapter.addTab(bar.newTab().setText(R.string.chill_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_ROSE);
    tabsAdapter.addTab(bar.newTab().setText(R.string.rose_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_INVERT);
    tabsAdapter.addTab(bar.newTab().setText(R.string.invert_filter), PhotoFragment.class, bundle);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.example.android.pm.shortcutlauncherdemo.ShortcutLauncherMain.java

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

    setContentView(R.layout.main);/*from  w  w w.  j ava  2s.  com*/

    mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setOffscreenPageLimit(2);
    mPagerAdapter = new MyPagerAdapter(getFragmentManager());
    mPager.setAdapter(mPagerAdapter);

    final ActionBar ab = getActionBar();
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ab.addTab(ab.newTab().setText("App list").setTabListener(mTabListener));
    ab.addTab(ab.newTab().setText("Pinned shortcuts").setTabListener(mTabListener));
}

From source file:com.dsdar.thosearoundme.tab.TMTabMainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tm_tab_activity_main);

    // Initilization
    viewPager = (ViewPager) findViewById(R.id.pager);
    actionBar = getActionBar();/*from   w ww  .j a  va  2  s.  c o  m*/
    mAdapter = new TabsPagerAdapter(getSupportFragmentManager());

    viewPager.setAdapter(mAdapter);
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Adding Tabs
    for (String tab_name : tabs) {
        actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this));
    }

    /**
     * on swiping the viewpager make respective tab selected
     * */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            // on changing the page
            // make respected tab selected
            actionBar.setSelectedNavigationItem(position);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
        }

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }
    });
}