title: When to update information for ViewPager?
body: <p>If I ave an <code>activity</code> with a <code>viewPAger</code> on it and two sets of data that I want to display, is it best to have one <code>fragment</code> and load information into <code>textViews</code> based on position passed from <code>activity</code> or better to create more than one fragment and load the one needed?<br>
  Any help is greatly appreciated. </p>
  
  <pre><code>public class testFragment extends Fragment {
      private static final String ARG_PAGE = "pageNumber";
      private static final int DEFAULT_INT = 0;
  
      TextView header, sd1;
      int h1, page = 0;
  
      public testFragment (){
      }
  
      public testFragment newInstance(int pageNumber) {
          testFragment fragment = new testFragment ();
          Bundle args = new Bundle();
          args.putInt(ARG_PAGE, pageNumber);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          if (getArguments() != null) {
              page = getArguments().getInt(ARG_PAGE);
          }
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
          ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_high_scores_page, container, false);
          return rootView;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          header = (TextView) getActivity().findViewById(R.id.modes_header);
          sd1 = (TextView) getActivity().findViewById(R.id.stat_det_1);
  
          switch (page) {
              case 1:
                  header.setText(R.string.easy_mode);
                  h1 = DEFAULT_INT;
                  sh1 =  DEFAULT_INT;
                  sd1.setText(String.valueOf(h1));
                  break;
  
              case 2:
                  header.setText(R.string.medium_mode);
                  h1 = DEFAULT_INT + 1;
                  sh1 =  DEFAULT_INT + 1;
                  sd1.setText(String.valueOf(h1));
                  break;
  
              default:
                  header.setText(R.string.action_restart);
                  h1 = DEFAULT_INT;        
                  sh1 = DEFAULT_INT;          
                  sd1.setText(String.valueOf(h1));
                  break;
          }
      }
  
      public void setTextViewInfo(){
          sd1.setText(String.valueOf(h1));
      }
  }
  </code></pre>
  
  <p>Or would it be better to send the information from my <code>activity</code> and load one or multiple <code>fragments</code> instead?</p>
  
  <pre><code>public class testActivity extends FragmentActivity  {
  
      private static final int NUM_PAGES = 8;
      private ViewPager mPager;
      private PagerAdapter mPagerAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.testActivity);
  
          // Instantiate a ViewPager and a PagerAdapter.
          mPager = (ViewPager) findViewById(R.id.high_scores_pager);
          mPagerAdapter = new testActivity (getSupportFragmentManager());
          mPager.setAdapter(mPagerAdapter);
      }
  
      @Override
      public void onBackPressed() {
          if (mPager.getCurrentItem() == 0) {
              super.onBackPressed();
          } else {
              mPager.setCurrentItem(mPager.getCurrentItem() - 1);
          }
      }
  
      private class testActivityAdapter extends FragmentStatePagerAdapter {
          public testActivityAdapter (FragmentManager fm) {
              super(fm);
          }
  
          @Override
          public Fragment getItem(int position) {
              switch (position) {
                  case 0:
                      testFragment tf1 = new testFragment ();
                      notifyDataSetChanged();
                      return easy.newInstance(position);
                  case 1:
                      testFragment2 tf2 = new testFragment ();
                      notifyDataSetChanged();
                      return medium.newInstance(position);
  
                  default:
                      testFragment d = new testFragment ();
                      return d.newInstance();
              }
          }
  
          @Override
          public int getItemPosition(Object object) {
              return super.getItemPosition(object);
          }
  
          @Override
          public int getCount() {
              return NUM_PAGES;
          }
      }
  }
  </code></pre>
  
  <p>edit:</p>
  
  <p>In my adapter, I just tried</p>
  
  <pre><code>@Override
  public Fragment getItem(int position) {
  switch (position) {
      case 0:
          return HighScoresEasyFragment.newInstance(position);
      case 1:
          return HighScoresMediumFragment.newInstance(position);
      case 2:
          return HighScoresExpertFragment.newInstance(position);
      case 3:
          return HighScoresBrainFartFragment.newInstance(position);
      case 4:
          return HighScoresClassicFragment.newInstance(position);
      case 5:
          return HighScoresPuzzleFragment.newInstance(position);
      case 6:
          return HighScoresPerfectFragment.newInstance(position);
      case 7:
          return HighScoresPowerFragment.newInstance(position);
      default:
          return HighScoresEasyFragment.newInstance(position);
  }
  </code></pre>
  
  <p>ugh, but it didn't load anything...  my <code>constructor</code> is now...:</p>
  
  <pre><code>public static HighScoresEasyFragment newInstance(int pageNumber) {
      HighScoresEasyFragment fragment = new HighScoresEasyFragment();
      Bundle args = new Bundle();
      args.putInt(ARG_PAGE, pageNumber);
      fragment.setArguments(args);
      return fragment;
  }
  </code></pre>
  
  <p>It loaded the first page's header but no data and it didn't load anything for second to 8th fragments...</p>