Skip to content

Instantly share code, notes, and snippets.

@appcoreopc
Created March 29, 2016 03:38
Show Gist options
  • Save appcoreopc/734767e3f6db1debc99a to your computer and use it in GitHub Desktop.
Save appcoreopc/734767e3f6db1debc99a to your computer and use it in GitHub Desktop.
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a PlaceholderFragment (defined as a static inner class below).
return PlaceholderFragment.newInstance(position + 1);
}
@Override
public int getCount() {
// Show 3 total pages.
return 3;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return "SECTION 1";
case 1:
return "SECTION 2";
case 2:
return "SECTION 3";
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment