title: Destroy previous ViewPager item preventing back scrolling
body: <p>I've added my code in below including some things I've tried. What I want is a sliding viewpager which doesn't allow you to through previous items but only forward. Preferably I would like to also only allow forward (right to left) scrolling if a certain checkbox is checked within the current fragment allowing progress to the next. </p>
  
  <p>I've considered </p>
  
  <ul>
  <li>removing the previous fragment once the current fragment is displayed and idle </li>
  <li>setting the adapter (i.e. this: <code>mPager.setAdapter(mPagerAdapter);</code>) again once I've reset the count and removed the first fragment to cause a "refresh"</li>
  <li>using an onTouchListener on the ViewPager and using motionevent</li>
  </ul>
  
  <p>The code below using <code>mPager.removeViewAt(0)</code> does not work as it doesn't prevent scrolling, just literally removes the view leaving a blank screen in it's place. </p>
  
  <p>What's the best way to do this? Maybe I'm not even using the right adapter as I've literally started using fragments from yesterday. </p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.viewpager);
      mPager = (ViewPager) findViewById(R.id.pager);
      mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
      mPager.setAdapter(mPagerAdapter);
      mPager.setOnPageChangeListener(mPageListener());
  }
  
  public OnPageChangeListener mPageListener() {
      OnPageChangeListener listener = new OnPageChangeListener() {
  
          public void onPageSelected(int arg0) {}
  
          public void onPageScrolled(int arg0, float arg1, int arg2) {}
  
          public void onPageScrollStateChanged(int arg0) {
              if (arg0 == ViewPager.SCROLL_STATE_IDLE &amp;&amp; mPager.getCurrentItem() != 0) {
                  mPager.removeViewAt(0);
                  mPagerAdapter.notifyDataSetChanged();
                  //mPagerAdapter.destroyItem(mPager, arg0, mPagerAdapter.getItem(arg0));
              }
          }
      };
      return listener;
  }
  
  private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
  
      public ScreenSlidePagerAdapter(FragmentManager fm) {
          super(fm);
      }
  
      @Override
      public Fragment getItem(int position) {
          Bundle args = new Bundle();
          args.putInt("position", position);
          Fragment fragment = new PracticeModeFragment();
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public int getCount() {
          return 5;
      }
  }
  
  public class PracticeModeFragment extends Fragment {
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.row,
                  container, false);
          ((TextView) rootView.findViewById(R.id.count)).setText(""
                  + getArguments().getInt("position"));
          return rootView;
  
      }
  
  }
  </code></pre>