List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getResourceView());/*from ww w. j a v a2 s . com*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); Locale l = Locale.getDefault(); // For each of the sections in the app, add a tab to the action bar. // Add the "Fragment" class to the tab's tag. The tab's "Fragment" will // be created using this class // Hour Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_hour).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Hour)); // Day Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_day).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Day)); // Week Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_week).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Week)); // Create the fragment adapter that will return a fragment based on the // Fragment class attached to the tab's tag object final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { final Fragment[] _fragments = new Fragment[3]; @Override public Fragment getItem(int position) { Tab tab = actionBar.getTabAt(position); if (tab != null) { if (_fragments[position] == null) { _fragments[position] = createTabFragment(tab); } } return _fragments[position]; } @Override public int getCount() { return actionBar.getTabCount(); } }; // Set up the ViewPager with the sections adapter. _viewPager = (ViewPager) findViewById(R.id.pager); _viewPager.setAdapter(pagerAdapter); // Keep all pages in memory _viewPager.setOffscreenPageLimit(2); // 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. _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); }
From source file:cmpe.alpha.fitwhiz.sensortag.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Log.d(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(mResourceFragmentPager); // Set up the action bar final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ImageView view = (ImageView) findViewById(android.R.id.home); view.setPadding(10, 0, 20, 10);/*from w w w . ja v a2 s . co m*/ // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(mResourceIdPager); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int n) { // Log.d(TAG, "onPageSelected: " + n); actionBar.setSelectedNavigationItem(n); } }); // Create the adapter that will return a fragment for each section mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mSectionsPagerAdapter); }
From source file:com.example.android.tabbedroombookingtimetabledisplay.MainFragmentActivity.java
public void tabSettings(ActionBar actionBar) { try {/*from www.j a v a 2 s . c om*/ actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); final Method setHasEmbeddedTabsMethod = actionBar.getClass().getDeclaredMethod("setHasEmbeddedTabs", boolean.class); setHasEmbeddedTabsMethod.setAccessible(true); setHasEmbeddedTabsMethod.invoke(actionBar, false); } catch (final Exception e) { // Handle issues as needed: log, warn user, fallback etc // This error is safe to ignore, standard tabs will appear. } }
From source file:com.borqs.browser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().addFlags(Window.FEATURE_ACTION_BAR); setResult(RESULT_CANCELED);// www. ja va 2 s.c o m Bundle extras = getIntent().getExtras(); Bundle args = extras.getBundle(EXTRA_COMBO_ARGS); String svStr = extras.getString(EXTRA_INITIAL_VIEW, null); ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks; mViewPager = new ViewPager(this); mViewPager.setId(R.id.tab_view); setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); if (BrowserActivity.isTablet(this)) { bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO); bar.setHomeButtonEnabled(true); } else { bar.setDisplayOptions(0); } mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), BrowserSnapshotPage.class, args); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0)); } else { switch (startingView) { case Bookmarks: mViewPager.setCurrentItem(0); break; case History: mViewPager.setCurrentItem(1); break; case Snapshots: mViewPager.setCurrentItem(2); break; } } }
From source file:com.mitchtodd.myweatherapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // create single instance of weather model to be used by activity and tab fragments. mWeatherModel = new WeatherModel(this); mWeatherModel.addOnGetWeatherStartedListener(onGetWeatherStartedListener); mWeatherModel.addOnGetWeatherFinishedListener(onGetWeatherFinishedListener); mWeatherModel.startWeatherUpdates(); setLastUpdatedText(true);//from w ww. jav a 2 s.c o m findViewById(R.id.refreshButton).setOnClickListener(onRefreshButtonClickListener); // create the adapter that will return a fragment for each of the 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); // set up swipe listener 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++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.norman0406.slimgress.ActivityOps.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ops); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); 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 . ja v a2 s. c om*/ 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.kosbrother.houseprice.ActionBarTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_bar_tabs); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // actionBar.setDisplayShowTitleEnabled(false); if (Build.VERSION.SDK_INT >= 14) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }//from w ww . ja v a2s .c o m actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing"))); actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi"))); actionBar.addTab(actionBar.newTab().setText("591") .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591"))); CallAds(); }
From source file:de.knufficast.ui.main.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); queueFragment = new QueueFragment(); feedsFragment = new FeedsFragment(); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setHomeButtonEnabled(false); // Set up the ViewPager with the sections adapter. viewPager = (ViewPager) findViewById(R.id.pager); viewPager.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./*ww w .j a v a2s . c o m*/ viewPager.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 < 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 // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setText(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:org.jorge.lolin1.ui.frags.NavigationDrawerFragment.java
/** * Per the navigation drawer design guidelines, updates the action bar to show the actionbar app * 'context', rather than just what's in the current screen. *//*www . j a va2s.c om*/ private void showGlobalContextActionBar() { ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(Boolean.TRUE); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(R.string.app_name); }
From source file:com.lugia.timetable.MasterActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_master); // Set up preferences value of this app if we run it on first time PreferenceManager.setDefaultValues(MasterActivity.this, R.xml.setting_preference, false); // Set up the action bar to show a dropdown list. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); mFilename = null;// w w w.j ava2 s. c o m mTimeTableFragment = new TimeTableFragment(); mSubjectListFragment = new SubjectListFragment(); getSupportFragmentManager().beginTransaction().add(R.id.container, mTimeTableFragment, "TimeTable") .add(R.id.container, mSubjectListFragment, "SubjectList").hide(mSubjectListFragment).commit(); mSpinnerAdapter = new TimeTableSpinnerAdapter(MasterActivity.this, actionBar.getSelectedNavigationIndex()); mSpinnerAdapter.setViewType(NAV_DAY); // Set up the dropdown list navigation in the action bar. actionBar.setListNavigationCallbacks(mSpinnerAdapter, this); }