title: android using ViewPager to show images
body: <p>I'd like to download a bunch of images from web and then show them using my custom PagerAdapter. So I can slide to browse all of these images.</p>
  
  <p>I define an activity named as <code>PhotoSlideActivity</code> which extends from <code>FragmentActivity</code>. In this activity, I have my own <code>PagerAdapter</code>. The following is my code: </p>
  
  <pre><code>    private class PhotoSlidePagerAdapter extends FragmentStatePagerAdapter {
          private final int mSize;
  
          public PhotoSlidePagerAdapter(FragmentManager fm, int size) {
              super(fm);
              mSize = size;
          }
  
          @Override
          public Fragment getItem(int position) {
              PhotoUrl photoUrl = new PhotoUrl(position);
              return PhotoSlidePageFragment.create(photoUrl.makePhotoUrl());
          }
  
          @Override
          public int getCount() {
              return mSize;
          }
      }
  </code></pre>
  
  <p>The following is my <code>PhotoSlidePageFragment</code>. <code>mImageFetcher</code> is a class which download images asynchronously.</p>
  
  <pre><code>   public class PhotoSlidePageFragment extends Fragment {
  
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
         final View v = inflater.inflate(R.layout.fragment_photo_slide_page, container, false);
         mImageView = (ImageView) v.findViewById(R.id.imageView1);
     }
  
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
  
         // Use the parent activity to load the image asynchronously into the ImageView
         if (PhotoSlideActivity.class.isInstance(getActivity())) {
            mImageFetcher = ((PhotoSlideActivity) getActivity()).getImageFetcher();
            mImageFetcher.loadImage(mImageUrl, mImageView);
         }
     }
  </code></pre>
  
  <p>(1) My original idea is to put <code>mImageFetcher.loadImage(mImageUrl, mImageView);</code> in <code>onCreateView</code>. Is there any difference between putting it in <code>onCreateView</code> and in <code>onActivityCreated</code>?</p>
  
  <p>(2) What if I replace what I did in <code>onActivityCreated</code> with <code>mImageFetcher = new ImageFetcher(); mImageFetcher.loadImage(mImageUrl, mImageView);</code>? Doing this means use <code>Fragment</code> to load the image asynchronously. Is there any bad effects doing this?</p>