List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:eu.chainfire.geolog.ui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// ww w. j a v a2 s . co m public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); invalidateOptionsMenu(); } }); mViewPager.setOffscreenPageLimit(3); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } int play = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); if (play == ConnectionResult.SUCCESS) { // Force database creation Database.Helper helper = Database.Helper.getInstance(this); helper.getReadableDatabase(); // Force Off profile as default SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); long id = prefs.getLong(SettingsFragment.PREF_CURRENT_PROFILE, 0); Database.Profile profile = Database.Profile.getById(helper, id, null); if (profile == null) id = 0; if (id == 0) { profile = Database.Profile.getOffProfile(helper); id = profile.getId(); prefs.edit().putLong(SettingsFragment.PREF_CURRENT_PROFILE, id).commit(); } // Start background service if (profile.getType() != Database.Profile.Type.OFF) BackgroundService.startService(this); } else { GooglePlayServicesUtil.getErrorDialog(play, this, 0).show(); finish(); } }
From source file:net.pejici.summation.SummationList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_summation_list); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); recreateSheetsList();// w ww . ja v a2 s. com }
From source file:com.albertcbraun.wifidlitedemoapp.fragments.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. ja v a 2 s . co m*/ private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(R.string.app_name); }
From source file:com.rastating.droidbeard.MainActivity.java
public void restoreActionBar() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); if (mTitle != null) { actionBar.setTitle(mTitle);//from ww w. j a va2 s . c om } }
From source file:de.ncoder.sensorsystem.android.app.MainActivity.java
private void onCreateTabs() { // Set up the action bar. final ActionBar actionBar = getActionBar(); if (actionBar == null) { return;/*from w w w . j a v a 2 s. c o m*/ } actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return tab fragments mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:app.screen.MyActivity.java
/** * For more info on using view pager and tabs and action bar, <a href="http://goo.gl/7CsM9">checkout this article</a> * in the Android developer site's "Training" section. * <p/>// w w w . j a v a 2 s . com * For more info on ViewPager, <a href="http://goo.gl/NgCUO">read this article</a>. */ private void _setupFragments() { // set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // create the FragmentPagerAdapter FragmentPagerAdapter fragmentPagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { @Override public Fragment getItem(int position) { try { return Fragments.values()[position].aClass.getConstructor(MyActivity.class) .newInstance(MyActivity.this); } catch (Exception e) { AndroidUtils.logErr(IconPaths.MyApp, "MyActivity - problem creating fragments", e); // something has gone wrong - this shouldn't happen return new Fragment() { /** make a fragment to house {@link R.layout#error_fragment} */ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return super.onCreateView(inflater, container, savedInstanceState); } }; } } @Override public int getCount() { return Fragments.values().length; } public CharSequence getPageTitle(int position) { try { return Fragments.values()[position].title; } catch (Exception e) { return "N/A"; } } }; // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. final ViewPager viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setOffscreenPageLimit(Fragments.values().length); // keep all the pages in memory viewPager.setAdapter(fragmentPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { /** * 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. */ @Override public void onPageSelected(int position) { super.onPageSelected(position); actionBar.setSelectedNavigationItem(position); } }); // create TabListener ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction transaction) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction transaction) { } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction transaction) { } }; // setup tabs for (int i = 0; i < fragmentPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(fragmentPagerAdapter.getPageTitle(i)).setTabListener(tabListener)); } }
From source file:com.klowerbase.test.ViewpagerAnimationActivity.java
@SuppressWarnings("deprecation") @Override/*w ww .jav a 2 s . c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int selectedPage = 0; if (savedInstanceState != null) { mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS); selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE); } final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<TransformerItem>( getApplicationContext(), android.R.layout.simple_expandable_list_item_1, android.R.id.text1, TRANSFORM_CLASSES); setContentView(R.layout.viewpageranimation); mAdapter = new PageAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.container); mPager.setAdapter(mAdapter); mPager.setCurrentItem(selectedPage); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setListNavigationCallbacks(actionBarAdapter, this); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //noinspection ResourceType actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE); actionBar.setSelectedNavigationItem(mSelectedItem); } }
From source file:com.ToxicBakery.viewpager.transforms.example.MainActivity.java
@SuppressWarnings("deprecation") @Override/*from w ww .j av a2s.c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int selectedPage = 0; if (savedInstanceState != null) { mSelectedItem = savedInstanceState.getInt(KEY_SELECTED_CLASS); selectedPage = savedInstanceState.getInt(KEY_SELECTED_PAGE); } final ArrayAdapter<TransformerItem> actionBarAdapter = new ArrayAdapter<TransformerItem>( getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1, TRANSFORM_CLASSES); setContentView(R.layout.activity_main); mAdapter = new PageAdapter(getFragmentManager()); mPager = (ViewPager) findViewById(R.id.container); mPager.setAdapter(mAdapter); mPager.setCurrentItem(selectedPage); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setListNavigationCallbacks(actionBarAdapter, this); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); //noinspection ResourceType actionBar.setDisplayOptions(actionBar.getDisplayOptions() ^ ActionBar.DISPLAY_SHOW_TITLE); actionBar.setSelectedNavigationItem(mSelectedItem); } }
From source file:org.mars3142.android.toaster.fragment.NavigationDrawerFragment.java
private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(R.string.app_name); }
From source file:com.example.team04adventure.Controller.OnlineStoryList.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_online_story_list); // 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// w w w .j a va 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)); } }