List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:run.ace.TabBar.java
public void show(android.app.Activity activity) { //if (!(activity instanceof ActionBarActivity)) { android.app.ActionBar mainActionBar = activity.getActionBar(); if (mainActionBar != null) { mainActionBar.show();//from www. j a v a2 s . c om mainActionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS); if (_primaryCommands != null) { for (int i = 0; i < _primaryCommands.size(); i++) { android.app.ActionBar.Tab tab = mainActionBar.newTab(); AppBarButton abb = (AppBarButton) _primaryCommands.get(i); if (abb.icon != null) { tab.setCustomView(getCustomTabView(abb, mainActionBar.getThemedContext())); } else { tab.setText(abb.label); } tab.setTabListener(this); mainActionBar.addTab(tab, i == 0); } } return; } throw new RuntimeException( "Cannot use TabBar on the main page in Android unless you set <preference name=\"ShowTitle\" value=\"true\"/> in config.xml."); //} //else { // ActionBar actionBar = ((ActionBarActivity)activity).getSupportActionBar(); // if (actionBar != null) { // actionBar.show(); // actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // for (int i = 0; i < _primaryCommands.size(); i++) { // ActionBar.Tab tab = actionBar.newTab(); // AppBarButton abb = (AppBarButton)_primaryCommands.get(i); // if (abb.icon != null) { // tab.setCustomView(getCustomTabView(abb, actionBar.getThemedContext())); // } // else { // tab.setText(abb.label); // } // tab.setTabListener(this); // actionBar.addTab(tab); // } // return; // } // throw new RuntimeException( // "Unable to get TabBar from the current activity."); //} }
From source file:com.hybris.mobile.activity.LoginActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); mViewPager = (ViewPager) findViewById(R.id.pager); Fragment[] frags = { new LoginFragment(), new RegistrationFragment() }; FragmentPagerAdapter adapter = new TabsAdapter(getFragmentManager(), frags); mViewPager.setAdapter(adapter);/*ww w .ja va 2 s . com*/ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); MyTabListener tabListener = new MyTabListener(mViewPager, actionBar); Tab tab = actionBar.newTab().setText(R.string.tab_login).setTabListener(tabListener); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.tab_register).setTabListener(tabListener); actionBar.addTab(tab); actionBar.setSelectedNavigationItem(0); // Handler to handle different asynchronous cases: // - When the user arrives from the scanning activity and scan a barcode that needs the user to be logged in, mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { // Error retrieving the data of the scanned value, we finish the activity and display a error message case BarCodeScannerActivity.MSG_DATA_ERROR: showMessage((String) msg.obj); finish(); break; // Data available, we can start the activity associated with the intent case BarCodeScannerActivity.MSG_DATA_AVAILABLE: if (mIntentBarcodeAfterLogin != null) { mIntentBarcodeAfterLogin.startActivity(); finish(); } break; } } }; }
From source file:com.decad3nce.aegis.AegisActivity.java
@Override public 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 om*/ setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setDisplayShowHomeEnabled(true); bar.setHomeButtonEnabled(true); bar.setTitle(R.string.app_name); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.alarm_section), SMSAlarmFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.lock_section), SMSLockFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.wipe_section), SMSWipeFragment.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.locate_section), SMSLocateFragment.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); alarmEnabled = preferences.getBoolean(PREFERENCES_ALARM_ENABLED, this.getResources().getBoolean(R.bool.config_default_alarm_enabled)); wipeEnabled = preferences.getBoolean(PREFERENCES_WIPE_ENABLED, this.getResources().getBoolean(R.bool.config_default_wipe_enabled)); lockEnabled = preferences.getBoolean(PREFERENCES_LOCK_ENABLED, this.getResources().getBoolean(R.bool.config_default_lock_enabled)); locateEnabled = preferences.getBoolean(PREFERENCES_LOCATE_ENABLED, this.getResources().getBoolean(R.bool.config_default_locate_enabled)); invalidateOptionsMenu(); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); }
From source file:com.stj.fileexplorer.FileExplorerTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // add begin by xugaoming@20140317, don't need to restore // fragments automaticaly if killed by system for memory, // it will mess up the logic savedInstanceState = null;/*from w w w.j ava2 s. co m*/ // add end super.onCreate(savedInstanceState); StorageHelper.getInstance(this); setContentView(R.layout.fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES); final ActionBar bar = getActionBar(); bar.hide(); 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); FileViewActivity fileViewActivity = ((FileViewActivity) getFragment(Util.SDCARD_TAB_INDEX)); fileViewActivity.registBottomBtnPressListener(this); /*mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);*/ int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB, Util.CATEGORY_TAB_INDEX); if (Intent.ACTION_PICK.equals(getIntent().getAction())) { selectedItem = Util.SDCARD_TAB_INDEX; } //add begin by xugaoming@20140517, add function to locate //to a directory Intent intent = getIntent(); if (intent != null && intent.getStringExtra("goto_dir") != null) { selectedItem = Util.SDCARD_TAB_INDEX; } //add end bar.setSelectedNavigationItem(0); }
From source file:com.ternup.caddisfly.fragment.NavigationDrawerFragment.java
/** * Per the navigation drawer design guidelines, updates the action bar to show the global app * 'context', rather than just what's in the current screen. *//*from w w w . j ava2s.com*/ private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(R.string.appName); }
From source file:edu.ufl.cise.android.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.// w ww . ja v a2 s . co m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayUseLogoEnabled(false); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.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 each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.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(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:awbb.droid.data.RatingActivity.java
/** * {@inheritDoc}// w w w . j av a 2s. co m */ @Override protected void onCreate(Bundle savedInstanceState) { // set theme ((AwbbApplication) getApplication()).applyTheme(this); // create activity super.onCreate(savedInstanceState); // data source DatabaseDataSource.create(this); DatabaseDataSource.open(); // load view setContentView(R.layout.activity_rating); viewPager = (ViewPager) findViewById(R.id.ratingPager); // get data from intent Intent intent = getIntent(); long id = intent.getLongExtra(EXTRA_RATING_ID, -1); // init if (id == -1) { rating = new Rating(); } else { rating = RatingDao.get(id); } // adapter adapter = new RatingPagerAdapter(this, getSupportFragmentManager()); viewPager.setAdapter(adapter); // action bar final ActionBar actionBar = getActionBar(); // FIXME // http://developer.android.com/training/implementing-navigation/lateral.html#horizontal-paging actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // ActionBar.TabListener tabListener = new ActionBar.TabListener() { // // @Override // public void onTabUnselected(Tab tab, FragmentTransaction ft) { // // TODO Auto-generated method stub // // } // // @Override // public void onTabSelected(Tab tab, FragmentTransaction ft) { // viewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabReselected(Tab tab, FragmentTransaction ft) { // // TODO Auto-generated method stub // // } // // }; // add tabs // for (int i = 0; i < Sensor.values().length + 1; i++) { // actionBar.addTab(actionBar.newTab().setText("tab" + // i).setTabListener(tabListener)); // } // page swipe viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { Log.d(TAG, "onPageSelected position=" + position); actionBar.setSelectedNavigationItem(position); }; }); }
From source file:co.nerdart.ourss.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(activity_main);/*from w ww . j a v a 2 s.com*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Hack to always show the tabs under the actionbar try { Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class); setHasEmbeddedTabsMethod.setAccessible(true); setHasEmbeddedTabsMethod.invoke(actionBar, false); } catch (Exception ignored) { } // Create the adapter that will return a fragment for each of the three // primary sections of the app. /* * The {@link android.support.v4.view.PagerAdapter} that will provide fragments for each of the sections. We use a {@link * android.support.v4.app.FragmentPagerAdapter} derivative, which will keep every loaded fragment in memory. If this becomes too memory * intensive, it may be best to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}. */ SectionsPagerAdapter sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(id.pager); mViewPager.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. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); invalidateOptionsMenu(); // Do not do it into onTabSelected()! } }); // 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)); } if (PrefUtils.getBoolean(PrefUtils.REFRESH_ENABLED, true)) { // starts the service independent to this activity startService(new Intent(this, RefreshService.class)); } else { stopService(new Intent(this, RefreshService.class)); } if (PrefUtils.getBoolean(PrefUtils.REFRESH_ON_OPEN_ENABLED, false)) { if (!FetcherService.isRefreshingFeeds) { startService(new Intent(MainActivity.this, FetcherService.class) .setAction(Constants.ACTION_REFRESH_FEEDS)); } } getSupportLoaderManager().initLoader(loaderId, null, this); }
From source file:fr.cph.chicago.fragment.drawer.NavigationDrawerFragment.java
/** * Per the navigation drawer design guidelines, updates the action bar to show the global app 'context', rather than just what's in the current * screen./*from w ww. j a v a 2s.c o m*/ */ private final void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(R.string.app_name); }
From source file:com.ape.filemanager.FileExplorerTabActivityOld.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); mIsMyOsOptionMenuStyle = getResources().getBoolean(R.bool.myos_option_menu_style); 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), FileCategoryActivityMyOS.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null); if (getResources().getBoolean(R.bool.have_cloud_file)) { mTabsAdapter.addTab(bar.newTab().setText(R.string.cloud_storage), CloudFileActivity.class, null); } else {/*w w w .ja v a 2s. c o m*/ mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); } int tabIndex; Intent intent = getIntent(); String action = intent.getAction(); if (getIntent().getData() != null) { tabIndex = Util.SDCARD_TAB_INDEX; } else if (!TextUtils.isEmpty(action)) { if (action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT) || action.equals("com.mediatek.filemanager.ADD_FILE")) { tabIndex = Util.CATEGORY_TAB_INDEX; } else if (action.equals(CloudFileUtil.CLOUD_STORAGE_ACTION)) { tabIndex = Util.REMOTE_TAB_INDEX; } else { tabIndex = Util.CATEGORY_TAB_INDEX; } } else { tabIndex = Util.CATEGORY_TAB_INDEX; //For market require. // tabIndex = PreferenceManager.getDefaultSharedPreferences(this) // .getInt(INSTANCESTATE_TAB, Util.CATEGORY_TAB_INDEX); } bar.setSelectedNavigationItem(tabIndex); mMountPointManager = MountPointManager.getInstance(); mMountPointManager.init(this); }