Example usage for android.app ActionBar setNavigationMode

List of usage examples for android.app ActionBar setNavigationMode

Introduction

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

Prototype

@Deprecated
public abstract void setNavigationMode(@NavigationMode int mode);

Source Link

Document

Set the current navigation mode.

Usage

From source file:com.christopher83.pkfmanager.PkfActivity.java

/**
 * Manages the activity creation/*from w w w. j  av a2  s. c o m*/
 */
protected void onCreate(Bundle savedInstanceState) {
    // Invoke the base class method
    super.onCreate(savedInstanceState);

    // Set the content of the activity view
    setContentView(R.layout.activity_pkf);

    // If the kernel that doesn't support the Phantom Key Presses Filter module, then show an alert dialog
    if (!isPkfSupported(this))
        showPkfNotSupportedAlert();

    // 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
    _sectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

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

    // 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
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        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 < _sectionsPagerAdapter.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(_sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.microsoft.band.sdksample.MainActivity.java

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

    // 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 activity.
    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/*w  ww .  j a  va  2  s . c om*/
        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.prolificcoder.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from   w  w w  .  ja  v a2s  .  c om*/
        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 < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:semanticweb.hws14.movapp.activities.Criteria.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_criteria);
    that = this;/*from   www . j a va 2  s  . c o  m*/
    initCriteriaView();

    //Get the Tabpager
    criteriaPagerAdapter = new CriteriaPagerAdapter(getSupportFragmentManager());
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(criteriaPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create a tab listener that is called when the user changes tabs.
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            mViewPager.setCurrentItem(tab.getPosition());
            tabPosition = tab.getPosition();
        }

        public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // hide the given tab
        }

        public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
            // probably ignore this event
        }
    };
    //add the two tabs
    actionBar.addTab(actionBar.newTab().setText("Movies").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("Actors").setTabListener(tabListener));
}

From source file:ca.cmput301f13t03.adventure_datetime.view.BrowseView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewpager);//from www  .  j av  a  2 s.  co m

    /* Set up View Pager */
    _adapter = new ViewPagerAdapter(getSupportFragmentManager());
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(_adapter);

    /* Set up Tabs */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            _viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        }
    };

    actionBar.addTab(actionBar.newTab().setText("Saved").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("My Stories").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("Online").setTabListener(tabListener));

    /* Change tabs when View Pager swiped */
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

}

From source file:org.jorge.lolin1.ui.frags.NavigationDrawerFragment.java

private void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(Boolean.TRUE);
    actionBar.setTitle(LoLin1Utils.getString(getActivity(),
            "title_section" + (DrawerLayoutFragmentActivity.getLastSelectedNavDrawerIndex() + 1), "Home"));
}

From source file:id.ridon.fileexplorer.FileExplorerTabActivity.java

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

    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES);

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

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_category), FileCategoryActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);
    bar.setSelectedNavigationItem(PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB,
            Util.CATEGORY_TAB_INDEX));
}

From source file:com.raypold.raypoldcounter.MainActivity.java

@Override
protected void onCreate(Bundle arg0) {

    super.onCreate(arg0);
    setContentView(R.layout.activity_main);

    context = getApplicationContext();/*from w w w.j  a va 2 s  .c om*/
    setFragmentManager();
    detectFirstRun();

    /*
     * Open the sharedPreference files for the actionBar functions extended
     * in ActionBarHandler
     */
    preferences = getSharedPreferences("userPreferences", 0);
    savedCounters = getSharedPreferences("savedCounters", 0);

    /* Create the action bar */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager()));

    setTabNames();

    /* Create the navigation tabs and add them to the action bar */
    for (String tabName : tabNames) {
        actionBar.addTab(actionBar.newTab().setText(tabName).setTabListener(this));
    }

    /* Synchronize the the swiping and the highlighted tab view */
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrollStateChanged(int arg0) {
        }

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

        @Override
        public void onPageSelected(int arg0) {
            actionBar.setSelectedNavigationItem(arg0);
        }
    });
}

From source file:org.mars3142.android.toaster.activity.MainActivity.java

private void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setTitle(mTitle);//from   www .  j av a  2s .c  om
    }
}

From source file:com.example.administrator.myapplication2._2_exercise._2_End._2_EndMain.java

/*****************************************************
 *    Overrided methods/* w  w w .  j a va 2s . com*/
 ******************************************************/

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

    //----- System, Context
    mContext = this; //.getApplicationContext();
    mActivityHandler = new ActivityHandler();
    AppSettings.initializeAppSettings(mContext);

    setContentView(R.layout._2_end_main);

    // 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 primary sections of the app.
    mFragmentManager = getSupportFragmentManager();
    mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

    // 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.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        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.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

}