Android Open Source - PlayTogether Sections Pager Adapter






From Project

Back to project page PlayTogether.

License

The source code is released under:

This is free and unencumbered software released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a co...

If you think the Android project PlayTogether listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.rockylearnstodevelop.playtogether;
//  ww  w .  jav a  2 s. c  o m
import java.util.Locale;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

  protected Context mContext;
  
  public SectionsPagerAdapter(Context context, FragmentManager fm) {
    super(fm);
    mContext = context;
  }

  @Override
  public Fragment getItem(int position) {
    // getItem is called to instantiate the fragment for the given page.
    // Return a DummySectionFragment (defined as a static inner class
    // below) with the page number as its lone argument.
    switch (position) {
      case 0:
        return new WannaPlayFragment();
      case 1:
        return new ActivitiesFragment();
      case 2:
        return new RequestFragment();
    }
    return null;
  }

  @Override
  public int getCount() {
    // Show 3 total pages.
    return 3;
  }

  @Override
  public CharSequence getPageTitle(int position) {
    Locale l = Locale.getDefault();
    switch (position) {
    case 0:
      return mContext.getString(R.string.title_section1);
    case 1:
      return mContext.getString(R.string.title_section2);
    case 2:
      return mContext.getString(R.string.title_section3);
    }
    return null;
  }
}




Java Source Code List

com.rockylearnstodevelop.playtogether.ActivitiesFragment.java
com.rockylearnstodevelop.playtogether.ActivityAdapter.java
com.rockylearnstodevelop.playtogether.FileHelper.java
com.rockylearnstodevelop.playtogether.ImageResizer.java
com.rockylearnstodevelop.playtogether.LoginActivity.java
com.rockylearnstodevelop.playtogether.MainActivity.java
com.rockylearnstodevelop.playtogether.MatchActivity.java
com.rockylearnstodevelop.playtogether.NoMatchActivity.java
com.rockylearnstodevelop.playtogether.ParseConstants.java
com.rockylearnstodevelop.playtogether.PlayWithMe2Application.java
com.rockylearnstodevelop.playtogether.RequestAdapter.java
com.rockylearnstodevelop.playtogether.RequestFragment.java
com.rockylearnstodevelop.playtogether.SectionsPagerAdapter.java
com.rockylearnstodevelop.playtogether.SignupActivity.java
com.rockylearnstodevelop.playtogether.UserInfoActivity.java
com.rockylearnstodevelop.playtogether.WannaPlayFragment.java