List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:com.villetainio.travelcardreminder.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter == null) { Toast.makeText(this, R.string.error_message_no_nfc_on_device, Toast.LENGTH_LONG).show(); finish();//from w ww .ja v a 2 s . co m } pagerAdapter = new TravelCardPagerAdapter(getSupportFragmentManager()); pager = (VerticalViewPager) findViewById(R.id.pager); pager.setAdapter(pagerAdapter); ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, android.app.FragmentTransaction ft) { pager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, android.app.FragmentTransaction ft) { // Unselect } @Override public void onTabReselected(ActionBar.Tab tab, android.app.FragmentTransaction ft) { // Reselect } }; actionBar.addTab(actionBar.newTab().setText("Status").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("Settings").setTabListener(tabListener)); } }
From source file:com.albertcbraun.wifidlitedemoapp.MainActivity.java
void restoreActionBar() { ActionBar actionBar = getActionBar(); //noinspection deprecation actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle);/*from w w w.java 2s .c o m*/ }
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// www. j a v a 2s. 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++) { // 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.geenk.fileexplorer.FileExplorerTabActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); 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_sd), // FileViewActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0)); }/*from w w w. j a v a2s .co m*/ }
From source file:com.androiduipatterns.smashingandroidui.examples.tabs.TabsExampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tabs_example); // 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 action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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.//from w w w. j a v a 2 s . com 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. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:net.networksaremadeofstring.rhybudd.FirstRunSettings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first_run_settings); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle(getString(R.string.FirstRunTitle)); actionBar.setSubtitle(getString(R.string.FirstRunSubtitle)); // 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 www . ja v 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++) { // 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:org.yuzhiqiang.itsmine.MainActivity.java
public void restoreActionBar() { final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(getTitle());//from w w w. j a v a 2s . com } }
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);//w ww . j a v a 2 s . co m 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.piusvelte.mosaic.android.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w . j ava 2s .c o m pagerAdapter = new MosaicPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < pagerAdapter.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 // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setText(pagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.intel.internal.telephony.mdmclitest.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.main); // Create the adapter that will return a fragment for each // primary sections of the app. like 'Modem Management BASIC OPS' operationTitleAdapter = new OperationTitleAdapter(super.getSupportFragmentManager(), this); // Set up the action bar. final ActionBar actionBar = super.getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager with the sections adapter. this.viewPager = (ViewPager) super.findViewById(R.id.pager); if (this.viewPager == null) { return;//from w w w . j av a 2 s .co m } String[] tabInfo = new String[0]; if (isDSDA) { tabInfo = getResources().getStringArray(R.array.tab_name); } else { viewPager.removeView(findViewById(R.id.pagertab)); } pageComponentList = new ArrayList<PageComponent>(); // Now we have two Action Bars: OperationTitle & SectionsPager // Delete the Page change listener of OperationTitle, // the swaping of SectionsPager only will be enabled. // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < operationTitleAdapter.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 // listener for when this tab is selected. CharSequence pageTitleName = operationTitleAdapter.getPageTitle(i); pageComponentList.add(new PageComponent(pageTitleName, new SectionsPagerAdapter(super.getSupportFragmentManager(), tabInfo))); actionBar.addTab(actionBar.newTab().setText(pageTitleName).setTabListener(this)); } PageComponent firstPage = pageComponentList.get(0); if ((null != firstPage)) { this.viewPager.setAdapter(firstPage.getFragmentPagerAdapter()); } }