Guest User

Untitled

a guest
Jul 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package com.example.android.viewpager;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v4.app.Fragment;
  5. import android.support.v4.app.FragmentManager;
  6. import android.support.v4.app.FragmentPagerAdapter;
  7.  
  8. public class SimpleFragmentPagerAdapter extends FragmentPagerAdapter {
  9. Bundle bundle = new Bundle();
  10. public SimpleFragmentPagerAdapter(FragmentManager fm) {
  11. super(fm);
  12. }
  13.  
  14. @Override
  15. public Fragment getItem(int position) {
  16. bundle.clear();
  17. if (position == 0) {
  18. WeekdayFragment mondayFragment = new WeekdayFragment();
  19. bundle.putInt("weekDay", R.layout.fragment_monday);
  20. mondayFragment.setBundle(bundle);
  21. return mondayFragment;
  22.  
  23. } else if (position == 1) {
  24. WeekdayFragment tuesdayFragment = new WeekdayFragment();
  25. bundle.putInt("weekDay", R.layout.fragment_tuesday);
  26. tuesdayFragment.setBundle(bundle);
  27. return tuesdayFragment;
  28.  
  29. } else if (position == 2) {
  30. WeekdayFragment wednesdayFragment = new WeekdayFragment();
  31. bundle.putInt("weekDay", R.layout.fragment_wednesday);
  32. wednesdayFragment.setBundle(bundle);
  33. return wednesdayFragment;
  34. } else if (position == 3) {
  35. WeekdayFragment thursdayFragment = new WeekdayFragment();
  36. bundle.putInt("weekDay", R.layout.fragment_thursday);
  37. thursdayFragment.setBundle(bundle);
  38. return thursdayFragment;
  39. } else {
  40. WeekdayFragment fridayFragment = new WeekdayFragment();
  41. bundle.putInt("weekDay", R.layout.fragment_friday);
  42. fridayFragment.setBundle(bundle);
  43. return fridayFragment;
  44. }
  45. }
  46.  
  47. @Override
  48. public int getCount() {
  49. return 5;
  50. }
  51. }
Add Comment
Please, Sign In to add comment