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.example.jenil.parsedemo.GameShowActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_game_show_adapter); // 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./*from w w w . j a va2s. c o m*/ 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.pagerShow); mViewPager.setAdapter(mAppSectionsPagerAdapter); 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:info.rti.tabsswipe.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Starting DDS subscriber as separate threaded task... if (BMP_pressureSubscriber.Pub_sub_create_count == 1) { ExecutorService service = Executors.newFixedThreadPool(4); service.submit(new Runnable() { @Override//from w w w.j ava2 s. c o m public void run() { String[] args = {}; // {"0", "2"}; BMP_pressureSubscriber.main(args); } }); BMP_pressureSubscriber.Pub_sub_create_count = 0; } //System.out.println("Pressure_high 0: " + mPressure_high); // System.out.println("Pressure_low 0: " + mPressure_low); // Initialization viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } /** * on swiping the viewpager make respective tab selected * */ viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page // make respected tab selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); }
From source file:net.vexelon.bgrates.ui.activities.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); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setTitle(R.string.app_name_pure); // actionBar.setDisplayUseLogoEnabled(true); // actionBar.setLogo(R.drawable.icon); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // 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/*from w w w . jav a 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)); } // load default values PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Start Service startService(); }
From source file:co.edu.uniajc.vtf.content.SwipeContentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swipe_content); //get the pager this.coAppSectionsPagerAdapter = new AppSectionsPagerAdapter(this.getSupportFragmentManager(), this); this.coViewPager = (ViewPager) findViewById(R.id.pagPagerContainer); this.coViewPager.setAdapter(coAppSectionsPagerAdapter); //get the action bar final ActionBar actionBar = this.getActionBar(); coViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*from www . j ava2 s. com*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.list48)); actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.map48)); actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.ra48)); actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.options48)); //get the google api client this.coApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_PROFILE).build(); }
From source file:ch.ethz.twimight.activities.ShowTweetListActivity.java
/** * Called when the activity is first created. *//*from www . j a v a 2s.c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.main); //statistics locDBHelper = new StatisticsDBHelper(getApplicationContext()); locDBHelper.open(); cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); timestamp = System.currentTimeMillis(); Bundle bundle = new Bundle(); bundle.putInt(ListViewPageAdapter.BUNDLE_TYPE, ListViewPageAdapter.BUNDLE_TYPE_TWEETS); pagAdapter = new ListViewPageAdapter(getFragmentManager(), bundle); viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(pagAdapter); viewPager.setOffscreenPageLimit(2); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the // corresponding tab. getActionBar().setSelectedNavigationItem(position); } }); //action bar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); Tab tab = actionBar.newTab().setIcon(R.drawable.ic_twimight_speech) .setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setIcon(R.drawable.ic_twimight_favorites) .setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setIcon(R.drawable.ic_twimight_mentions) .setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); }
From source file:transapps.gpxfitness.ui.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. actionBar = getActionBar();/*from www . ja va2s . co m*/ // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. 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.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().setIcon(mAppSectionsPagerAdapter.getPageIconUnselected(i)) .setTabListener(this)); } mViewPager.setCurrentItem(2); if (!ProfileAccessor.isProfileSet()) { profileAlertDialog(); } // actionBar.setTitle(this.getString(R.string.app_name) + ": " + ProfileAccessor.getUsername()); }
From source file:net.evenh.chargingstations.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set default values PreferenceManager.setDefaultValues(this, R.xml.preferences, false); // Check for internet connectivity dialog = new AlertDialog.Builder(this).setTitle(R.string.internet_dialog_title) .setMessage(R.string.internet_dialog_message).setCancelable(true) .setNegativeButton(R.string.internet_dialog_cancel, new DialogInterface.OnClickListener() { @Override//from w w w. j av a 2 s . c om public void onClick(DialogInterface dialog, int which) { finish(); } }).setPositiveButton(R.string.internet_dialog_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (!hasClicked) { hasClicked = true; startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)); hasClicked = false; } } }).create(); // Check for Google Play Services int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); if (status == ConnectionResult.SUCCESS) { TabAdapter = new TabPagerAdapter(getFragmentManager()); Tab = (ViewPager) findViewById(R.id.pager); Tab.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar = getActionBar(); actionBar.setSelectedNavigationItem(position); } }); Tab.setAdapter(TabAdapter); actionBar = getActionBar(); //Enable Tabs on Action Bar if (actionBar != null) actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabReselected(android.app.ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { Tab.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(android.app.ActionBar.Tab tab, FragmentTransaction ft) { } }; //Add New Tab actionBar.addTab(actionBar.newTab().setText(R.string.near_me).setIcon(R.drawable.ic_action_place) .setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText(R.string.search).setIcon(R.drawable.ic_action_search) .setTabListener(tabListener)); } else { // Google Play Services error handling Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, -1); dialog.show(); } }
From source file:com.yohpapa.overlaymusicplayer.activity.MainActivity.java
private void setupActionBar() { ActionBar bar = getActionBar();//from w ww .java2 s . c o m bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayShowHomeEnabled(false); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); int lastPosition = PrefUtils.getInt(this, R.string.pref_last_tab_position, 0); for (int i = 0; i < fragmentNames.length; i++) { ActionBar.Tab tab = bar.newTab(); tab.setText(fragmentNames[i]); tab.setTabListener(new ActionBar.TabListener() { @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { Log.d(TAG, "onTabUnselected"); } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { ViewPager pager = (ViewPager) findViewById(R.id.fragment_pager); pager.setCurrentItem(tab.getPosition()); PrefUtils.setInt(MainActivity.this, R.string.pref_last_tab_position, tab.getPosition()); } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { Fragment fragment = fragments[tab.getPosition()]; if (fragment instanceof CommonListFragment) { ((CommonListFragment) fragment).onTapWhenSelected(); } } }); boolean isSelected = false; if (i == lastPosition) { isSelected = true; } bar.addTab(tab, isSelected); } }
From source file:com.christopher83.pkfmanager.PkfActivity.java
/** * Manages the activity creation/*from w ww . j ava 2s . co m*/ */ protected void onCreate(Bundle savedInstanceState) { // Invoke the base class method super.onCreate(savedInstanceState); // Set the content of the activity view setContentView(R.layout.activity_pkf); // If the kernel that doesn't support the Phantom Key Presses Filter module, then show an alert dialog if (!isPkfSupported(this)) showPkfNotSupportedAlert(); // 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 _sectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // 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 _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { 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 callback (listener) for when this tab is selected actionBar .addTab(actionBar.newTab().setText(_sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:ca.cmput301f13t03.adventure_datetime.view.AuthorEdit.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewpager);// www. j a v a 2 s .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); }