Back to project page ScienceQuiz.
The source code is released under:
GNU General Public License
If you think the Android project ScienceQuiz listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.finger.sciencequiz; /*from w ww. j a v a 2s. c om*/ import java.util.Locale; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.content.Context; import com.finger.sciencequiz.R; /** * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ public class HomePagerAdapter extends FragmentPagerAdapter { private Context Context; public HomePagerAdapter (FragmentManager fm, Context context) { super (fm); Context = context; } @Override public Fragment getItem (int position) { // getItem is called to instantiate the fragment for the given page. // Return a Fragment with the page number as its lone argument. Fragment fragment = null; switch (position) { case 0: fragment = new RunningGamesHomeFragment (); break; case 1: fragment = new StartHomeFragment (); break; case 2: fragment = new FriendsHomeFragment (); break; case 3: fragment = new ProfileHomeFragment (); break; } return fragment; } @Override public int getCount () { // Show 4 total pages. return 4; } @Override public CharSequence getPageTitle (int position) { Locale l = Locale.getDefault (); switch (position) { case 0: return Context.getString (R.string.running_games).toUpperCase (l); case 1: return Context.getString (R.string.start).toUpperCase (l); case 2: return Context.getString (R.string.friends).toUpperCase (l); case 3: return Context.getString (R.string.profile).toUpperCase (l); } return null; } }