List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS
int NAVIGATION_MODE_TABS
To view the source code for android.app ActionBar NAVIGATION_MODE_TABS.
Click Source Link
From source file:com.baohume.browser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);/* w w w . j a va 2s .c o m*/ Bundle extras = getIntent().getExtras(); Bundle args = extras.getBundle(EXTRA_COMBO_ARGS); String svStr = extras.getString(EXTRA_INITIAL_VIEW, null); UI.ComboViews startingView = svStr != null ? UI.ComboViews.valueOf(svStr) : UI.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.g_node.gca.schedule.ScheduleMainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i("GCA-Performance", "In Oncreate of ScheduleMain"); Log.i("GCA-Performance", "in on Create - Time: " + System.currentTimeMillis()); setContentView(R.layout.activity_schedule_main_viewpager); //ArrayLists are already populated during splash screen activity so let's move to initialization // Initilization viewPager = (ViewPager) findViewById(R.id.schedulePager); actionBar = getActionBar();/* w w w .ja va 2 s .c o m*/ actionBar.setIcon(getResources().getDrawable(R.drawable.icon_schedule_actionbar)); actionBar.setDisplayHomeAsUpEnabled(true); mAdapter = new SchedulePagerAdapter(getSupportFragmentManager()); mAdapter.setLists(scheduleRecordsArray, eventsRecordsArray, tracksRecordsArray, sessionRecordsArray, dateWiseEventsRecordList); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 0; i < dateWiseEventsRecordList.size(); i++) { DateWiseEventsRecord temp = dateWiseEventsRecordList.get(i); actionBar.addTab(actionBar.newTab().setText(temp.get_formated_date()).setTabListener(this)); } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { // TODO Auto-generated method stub Log.i(LOG_TAG, "at 100 of schedule activity"); // actionBar.setSelectedNavigationItem(1); Log.i(LOG_TAG, "at 102 of schedule activity"); //supportInvalidateOptionsMenu(); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { // TODO Auto-generated method stub } @Override public void onPageSelected(int arg0) { // TODO Auto-generated method stub actionBar.setSelectedNavigationItem(arg0); } }); }
From source file:com.android.browser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);/*from ww w.jav a2 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); 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.android.xbrowser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);// w w w . ja v a2 s .c om 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); } 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.raypold.raypoldcounter.MainActivity.java
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.activity_main); context = getApplicationContext();/*from ww w . ja va 2s. co m*/ setFragmentManager(); detectFirstRun(); /* * Open the sharedPreference files for the actionBar functions extended * in ActionBarHandler */ preferences = getSharedPreferences("userPreferences", 0); savedCounters = getSharedPreferences("savedCounters", 0); /* Create the action bar */ final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(new FragmentAdapter(getSupportFragmentManager())); setTabNames(); /* Create the navigation tabs and add them to the action bar */ for (String tabName : tabNames) { actionBar.addTab(actionBar.newTab().setText(tabName).setTabListener(this)); } /* Synchronize the the swiping and the highlighted tab view */ viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(int arg0) { actionBar.setSelectedNavigationItem(arg0); } }); }
From source file:com.android.stockbrowser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);//from w w w .j a v a 2s . 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.piusvelte.mosaic.android.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w . jav a 2s. co m pagerAdapter = new MosaicPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.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 (int i = 0; i < pagerAdapter.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(pagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.androiduipatterns.smashingandroidui.examples.tabs.TabsExampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tabs_example); // 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 action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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.//from www.j a v a 2 s.co m 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++) { // 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(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
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/*from www. j ava 2 s . c o 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: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/* w ww. 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)); } } }