title: Android - How to "invalidate" a Fragment in a FragmentPagerAdapter?
body: <p>I have an Android FragmentPagerAdapter that uses BitmapFragment (below), and it works great. Now I'm trying to switch out the Images on the fly. I've tried changing the ImageView but nothing changes. And I've tried using a FragmentTransaction.replace to swap it out, but I get an Invalid Argument exception. I know getImageViewAtPage() works and "bitmap" is a valid Bitmap.</p>
  
  <p>Thanks!</p>
  
  <pre><code>private class BitmapFragment extends Fragment {
      private int mPosition = 0;
      private ImageView mImageView;
  
      private BitmapFragment(int num){
          super();
          mPosition = num;
      }
  
      public ImageView getImageView(){
          return mImageView;
      }
  
      /**
       * The Fragment's UI is just a Bitmap
       */
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment_bitmap, container, false);
          try{
              mImageView = (ImageView) v.findViewById(R.id.bitmap);
              mImageView.setImageBitmap(bitmap);   
          }
          catch(Exception e){
              e.printStackTrace();
          }
          return v;
      }
  }
  
          private void changeImage() {
              /*
  
              BitmapFragment bf = new BitmapFragment(mCurrentPageIndex);
              FragmentTransaction ft = mReaderViewHandler.getSupportFragmentManager().beginTransaction();
              ft.replace(R.layout.fragment_bitmap, bf);
              ft.commit();
      */
              ImageView v = getImageViewAtPage(mCurrentPageIndex);
              try {
                  v.setImageBitmap(bitmap);
              } catch (Exception e) {
  
                  e.printStackTrace();
              }
              v.invalidate();
          }
  </code></pre>