title: FragmentPagerAdapter getItem is not being triggered
body: <p>Currently, with a <code>FragmentActivity</code>, I toggle among 2 type of Fragments using the following code.</p>
  
  <pre><code>private void toggle() {
      Fragment oldFragment = getSupportFragmentManager().findFragmentById(R.id.content);
      Fragment fragment = null;
      if (oldFragment instanceof ColorFragment) {
          fragment = new ViewPagerFragment();
      } else {
          fragment = new ColorFragment(android.R.color.black);
      }
  
      getSupportFragmentManager().beginTransaction().replace(R.id.content, fragment).commitAllowingStateLoss();
  }
  </code></pre>
  
  <p>2 Fragments are being toggle.</p>
  
  <ul>
  <li><strong>ColorFragment</strong> - A simple fragment which fill up its background with solid black color.</li>
  <li><strong>ViewPagerFragment</strong> - A fragment contains <code>ViewPager</code>. User can swipe between a purple color fragment, and a blue color fragment.</li>
  </ul>
  
  <p>The code which responsible for swiping purple and blue color fragments are as below.</p>
  
  <pre><code>private static class MyFragmentPagerAdapter extends FragmentPagerAdapter {
  
      public MyFragmentPagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public int getCount() {
          return 2;
      }
  
      @Override
      public Fragment getItem(int position) {
          switch (position) {
          case 0:
              return new ColorFragment(android.R.color.holo_purple);
          default:
              return new ColorFragment(android.R.color.holo_blue_bright);
          }
      }      
  } 
  </code></pre>
  
  <p>However, I encounter the weird behavior during toggling.</p>
  
  <ol>
  <li>Black color fragment was shown.</li>
  <li>Toggling.</li>
  <li>View pager, which can swipe between purple and blue fragments shown.</li>
  <li>Toggling.</li>
  <li>Black color fragment was shown.</li>
  <li>Toggling.</li>
  <li><strong>Nothing shown, as MyFragmentPagerAdapter's getItem is not being triggered.</strong></li>
  </ol>
  
  <p>I think my situation is similar to <a href="https://stackoverflow.com/questions/12581896/fragmentpageradapter-getitem-is-not-called">FragmentPagerAdapter getItem is not called</a></p>
  
  <p>However, I prefer not to use <code>FragmentStatePagerAdapter</code>, because of <em>the cost of potentially more overhead when switching between pages.</em></p>
  
  <p>Any workaround to overcome this problem?</p>
  
  <p>I include a complete workable source code to demonstrate this problem : <a href="https://www.dropbox.com/s/jok9tz5ktvfcteo/viewpagerbug.zip" rel="nofollow noreferrer">https://www.dropbox.com/s/jok9tz5ktvfcteo/viewpagerbug.zip</a></p>