Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.viewpager;
- import android.os.Bundle;
- import android.support.v4.app.Fragment;
- import android.support.v4.app.FragmentManager;
- import android.support.v4.app.FragmentPagerAdapter;
- public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
- Bundle bundle = new Bundle();
- public SimpleFragmentPagerAdapter(FragmentManager fm) {
- super(fm);
- }
- @Override
- public Fragment getItem(int position) {
- bundle.clear();
- if (position == 0) {
- WeekdayFragment mondayFragment = new WeekdayFragment();
- bundle.putInt("weekDay", R.layout.fragment_monday);
- mondayFragment.setBundle(bundle);
- return mondayFragment;
- } else if (position == 1) {
- WeekdayFragment tuesdayFragment = new WeekdayFragment();
- bundle.putInt("weekDay", R.layout.fragment_tuesday);
- tuesdayFragment.setBundle(bundle);
- return tuesdayFragment;
- } else if (position == 2) {
- WeekdayFragment wednesdayFragment = new WeekdayFragment();
- bundle.putInt("weekDay", R.layout.fragment_wednesday);
- wednesdayFragment.setBundle(bundle);
- return wednesdayFragment;
- } else if (position == 3) {
- WeekdayFragment thursdayFragment = new WeekdayFragment();
- bundle.putInt("weekDay", R.layout.fragment_thursday);
- thursdayFragment.setBundle(bundle);
- return thursdayFragment;
- } else {
- WeekdayFragment fridayFragment = new WeekdayFragment();
- bundle.putInt("weekDay", R.layout.fragment_friday);
- fridayFragment.setBundle(bundle);
- return fridayFragment;
- }
- }
- @Override
- public int getCount() {
- return 5;
- }
- }
Add Comment
Please, Sign In to add comment