List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:ca.cmput301f13t03.adventure_datetime.view.AuthorEdit.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewpager);/*from www. ja v a2s. c om*/ /* 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("Edit").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("Overview").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("Preview").setTabListener(tabListener)); /* Change tabs when View Pager swiped */ _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); // Select 'Overview' at start getActionBar().setSelectedNavigationItem(1); }
From source file:de.grobox.liberario.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.pager); final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override//from ww w. j a v a2s . co m public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // show the given tab mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // hide the given tab } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // probably ignore this event } }; List<String> fragments = new ArrayList<String>(); fragments.add(DirectionsFragment.class.getName()); actionBar.addTab( actionBar.newTab().setIcon(android.R.drawable.ic_menu_directions).setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_star).setTabListener(tabListener)); fragments.add(FavTripsFragment.class.getName()); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_tab_stations).setTabListener(tabListener)); fragments.add(StationsFragment.class.getName()); mainPagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), this, fragments); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the corresponding tab. getActionBar().setSelectedNavigationItem(position); } }); mViewPager.setAdapter(mainPagerAdapter); // show Changelog HoloChangeLog cl = new HoloChangeLog(this); if (cl.isFirstRun() && !cl.isFirstRunEver()) { cl.getLogDialog().show(); } }
From source file:fr.android.earthdawn.activities.CharacterSheetActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager);//w ww .j a v a 2s . com setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); mTabsAdapter = new TabsAdapter(this, mViewPager); // Load character and store it in bundle final EDCharacter character = CharacterManager.getLoadedCharacter(); Bundle bundle; // Infos gnrales mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_description), CharacterFragment.class, null); // Talents, par discipline if (character.getMainDiscipline() != null) { bundle = new Bundle(1); bundle.putSerializable(Constants.BUNDLE_DISCIPLINE, character.getMainDiscipline()); mTabsAdapter.addTab(bar.newTab().setText(character.getMainDiscipline().getName()), TalentsFragment.class, bundle); } if (character.getSecondDiscipline() != null) { bundle = new Bundle(1); bundle.putSerializable(Constants.BUNDLE_DISCIPLINE, character.getSecondDiscipline()); mTabsAdapter.addTab(bar.newTab().setText(character.getSecondDiscipline().getName()), TalentsFragment.class, bundle); } if (character.getThirdDiscipline() != null) { bundle = new Bundle(1); bundle.putSerializable(Constants.BUNDLE_DISCIPLINE, character.getThirdDiscipline()); mTabsAdapter.addTab(bar.newTab().setText(character.getThirdDiscipline().getName()), TalentsFragment.class, bundle); } // Equipment mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_stuff), EquipmentFragment.class, null); // Skill mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_skills), SkillsFragment.class, null); // TODO Grimoire if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(TAB, 0)); } }
From source file:com.afollestad.overhear.ui.OverviewScreen.java
/** * Sets up the action bar tabs and the view pager. *///from www . j a v a2 s . co m private void setupTabs() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(5); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar.TabListener mTabListener = new ActionBar.TabListener() { @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { invalidateOptionsMenu(); mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { Fragment frag = getFragmentManager().findFragmentByTag("page:" + tab.getPosition()); if (frag instanceof ListFragment) { if (frag.getView() != null) ((ListFragment) frag).getListView().setSelection(0); } else if (frag instanceof OverhearGridFragment) { if (frag.getView() != null) ((OverhearGridFragment) frag).getListView().setSelection(0); } } }; for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) actionBar.addTab( actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(mTabListener)); actionBar.setSelectedNavigationItem(Store.i(this, "focused_tab", 2)); }
From source file:com.aogp.about.AboutActivity.java
/** Called when the activity is first created. */ @Override/*from ww w.ja v a 2s .co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); appContext = getApplicationContext(); ActionBar actionbar = getActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionbar.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.about_tab_title), AboutFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.features_tab_title), FeaturesFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.aogp_tab_title), AOGPFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.contributors_tab_title), ContributorsFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.testers_tab_title), TestersFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.social_tab_title), SocialFragment.class, null); }
From source file:com.mastercard.masterpasswallet.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. */// www . j a v a 2 s .c o m private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); }
From source file:de.WyLight.WyLight.WiflyControlActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (null != savedInstanceState) { mARGB = savedInstanceState.getInt(STATE_KEY_COLOR, 0xffffffff); Color.colorToHSV(mARGB, mHSV); }/* w w w . j a va 2 s . co m*/ setContentView(R.layout.view_pager); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); final ViewPager pager = (ViewPager) findViewById(R.id.pager); final WiflyPagerAdapter adapter = new WiflyPagerAdapter(getFragmentManager()); pager.setAdapter(adapter); pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { public void onPageScrolled(int arg0, float arg1, int arg2) { /* not implemented */ } public void onPageScrollStateChanged(int arg0) { /* not implemented */ } public void onPageSelected(int arg0) { getActionBar().setSelectedNavigationItem(arg0); mFragments[arg0].onShow(mMenu); } }); TabListener listener = new TabListener(pager); for (int i = 0; i < pager.getAdapter().getCount(); ++i) { Tab tab = actionBar.newTab().setIcon(mFragments[i].getIcon()).setTabListener(listener); actionBar.addTab(tab); } Intent i = getIntent(); mRemote = (Endpoint) i.getSerializableExtra(EXTRA_ENDPOINT); }
From source file:com.veggies.android.todoList.MainActivity.java
private void hideActionMenu() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); }
From source file:org.ounl.lifelonglearninghub.nfcecology.swipe.SwipeActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swipe); // 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(); actionBar.setHomeButtonEnabled(true); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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//www .j ava 2s . c o m 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:com.veggies.android.todoList.MainActivity.java
private void setActionMenu() { isDisplayAllList = false;/*from w w w. ja v a 2s .c o m*/ ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(spinnerAdapter, new DropDownListenser()); }