List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:fr.cph.chicago.activity.BusBoundActivity.java
@Override public final boolean onCreateOptionsMenu(final Menu menu) { super.onCreateOptionsMenu(menu); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(this.mBusRouteName + " (" + this.mBound + ")"); return true;// w ww.ja va 2s .c o m }
From source file:name.gumartinm.weather.information.activity.MainTabsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.weather_main_tabs); this.mPager = (ViewPager) this.findViewById(R.id.pager); this.mPager.setAdapter(new TabsAdapter(this.getSupportFragmentManager())); this.mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w ww . j av a2 s .c om public void onPageSelected(final int position) { MainTabsActivity.this.getActionBar().setSelectedNavigationItem(position); } }); final ActionBar actionBar = this.getActionBar(); PreferenceManager.setDefaultValues(this, R.xml.weather_preferences, false); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); actionBar.setDisplayHomeAsUpEnabled(true); // Create a tab listener that is called when the user changes tabs. final ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(final Tab tab, final FragmentTransaction ft) { MainTabsActivity.this.mPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(final Tab tab, final FragmentTransaction ft) { } @Override public void onTabReselected(final Tab tab, final FragmentTransaction ft) { } }; actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_currently)) .setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(this.getString(R.string.text_tab_five_days_forecast)) .setTabListener(tabListener)); }
From source file:ca.mymenuapp.ui.activities.MainActivity.java
/** Setup the tabs to display our fragments. */ private void setupTabs(int tab) { DelegateOnPageChangeListener delegateOnPageChangeListener = new DelegateOnPageChangeListener(); viewPager.setOnPageChangeListener(delegateOnPageChangeListener); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); SwipeableActionBarTabsAdapter tabsAdapter = new SwipeableActionBarTabsAdapter(this, viewPager, delegateOnPageChangeListener); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.map)), RestaurantsMapFragment.class, null); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.specials)), SpecialsGridFragment.class, null);/*from w w w .j a v a2 s . c o m*/ if (!userPreference.get().isGuest()) { tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.dietary_preferences)), DietaryPreferencesFragment.class, null); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.settings)), SettingsFragment.class, null); } actionBar.setSelectedNavigationItem(tab); delegateOnPageChangeListener.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (position == 0) { // Enable user to slide the drawer layout drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); drawerToggle.setDrawerIndicatorEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); } else { // Disable user from sliding the drawer layout drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerToggle.setDrawerIndicatorEnabled(false); getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false); } } @Override public void onPageSelected(int position) { // ignore } @Override public void onPageScrollStateChanged(int state) { // ignore } }); }
From source file:com.blueoxfords.peacecorpstinder.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); activity = this; mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(this, getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(2); final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(false); actionBar.setTitle(getString(R.string.app_name)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*from w w w . j a v a 2 s . c o m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } } }
From source file:com.dragamstudios.waarisdezon.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 w w .j a v a 2s .com*/ actionBar.setHomeButtonEnabled(false); // 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.setOffscreenPageLimit(3); 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:blackman.matt.infinitebrowser.InfinityBrowser.java
/** * Restores the action bar when called./* w w w .j a v a 2 s . co m*/ */ void restoreActionBar() { ActionBar actionBar = getActionBar(); assert actionBar != null; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); }
From source file:com.imobilize.blogposts.fragments.SubscribeFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ActionBar actionBar = getActivity().getActionBar(); actionBar.setDisplayShowTitleEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); rootView = inflater.inflate(R.layout.login, container, false); context = getActivity().getApplicationContext(); declareCheckBoxes();//from w w w . j ava 2 s . c o m declareRegisterButton(); enableDisableButton(); enableDisableCheckBoxes(); return rootView; }
From source file:com.ijunes.transitions.StoryDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_story_detail); if (savedInstanceState == null) { // Load the data from the intent on first pass Intent intent = getIntent();//from ww w . j a v a 2 s.c om String story_id = intent.getStringExtra(ARG_STORY_ID); mItem = StoryContent.STORY_MAP.get(story_id); } // Get hold of some relevant content final ViewGroup container = (ViewGroup) findViewById(R.id.container); // What are the layouts we should be able to transition between List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01, R.layout.content_scene_02); // Create the scenes sceneList = new ArrayList<Scene>(); for (int layout : sceneLayouts) { // Create the scene Scene scene = Scene.getSceneForLayout(container, layout, this); // Just before the transition starts, ensure that the content has been loaded scene.setEnterAction(new Runnable() { @Override public void run() { addContentToViewGroup(container); } }); // Save the scene into sceneList.add(scene); } // Build the transition manager TransitionInflater transitionInflater = TransitionInflater.from(this); mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager, container); // Show the Up button in the action bar. final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); // Specify we want some tabs actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a listener to cope with tab changes tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // If there's a scene for this tab index, then transition to it if (tab.getPosition() <= sceneList.size()) { tabPosition = tab.getPosition(); performTransitionToScene(sceneList.get(tab.getPosition())); } } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // Can ignore this event } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // Can ignore this event } public void performTransitionToScene(Scene scene) { mTransitionManager.transitionTo(scene); } }; // Add some tabs for (int i = 0; i < sceneList.size(); i++) { actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener)); } } // Load the first scene sceneList.get(0).enter(); }
From source file:com.bonsai.btcreceive.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Turn off "up" navigation since we are the top-level. getSupportActionBar().setDisplayHomeAsUpEnabled(false); setContentView(R.layout.activity_main); mAdapter = new MyAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter);/* w w w . ja v a 2 s . c om*/ // Specify that tabs should be displayed in the action bar. final android.app.ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. TabListener tabListener = new TabListener() { @Override public void onTabReselected(Tab tab, android.app.FragmentTransaction ft) { } @Override public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) { // show the given tab int position = tab.getPosition(); manageKeyboard(position); mPager.setCurrentItem(position); } @Override public void onTabUnselected(Tab tab, android.app.FragmentTransaction ft) { } }; // Add tabs to the view pager. actionBar.addTab( actionBar.newTab().setText(mRes.getString(R.string.tab_receive)).setTabListener(tabListener)); actionBar.addTab( actionBar.newTab().setText(mRes.getString(R.string.tab_transactions)).setTabListener(tabListener)); actionBar.addTab( actionBar.newTab().setText(mRes.getString(R.string.tab_account)).setTabListener(tabListener)); // Listen for swiped changes to the view pager. mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the // corresponding tab. manageKeyboard(position); getActionBar().setSelectedNavigationItem(position); } }); mLogger.info("MainActivity created"); }
From source file:com.actionbarsherlock.sample.styled.MainActivityICS.java
private void showTabsNav() { ActionBar ab = getActionBar(); if (ab.getNavigationMode() != ActionBar.NAVIGATION_MODE_TABS) { ab.setDisplayShowTitleEnabled(true); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }/*from w w w . ja v a 2 s. c o m*/ }