title: ViewPager works Fine at first time but on reloading again, getting the error java.lang.IllegalStateException?
body: <p>I have a ViewPager with the 10 images comes through webservices(JSON), At first ViewPager work smoothly (fine).</p>
  
  <p><strong>but When back from the activity and reopen it again</strong>  <strong>I got this error :</strong></p>
  
  <pre><code>java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! 
  
  Expected adapter item count: 10, found: 0 Pager id: com.akm.demo.activities:id/slideShowPager Pager class: class android.support.v4.view.ViewPager 
  </code></pre>
  
  <p><strong>In main Activity class</strong></p>
  
  <pre><code>if (mSlideShowData != null) { // mSlideShowData is An ArrayList of the Images Which I pass to ImagePagerAdapter
  adapter = new ImagePagerAdapter(getContext(), mSlideShowData);
  slideShowPager.setAdapter(adapter);
  
  //slideShowPager.invalidate();
  ((PagerAdapter)slideShowPager.getAdapter()).notifyDataSetChanged(); 
  }
  
   else{
  Toast toast = Toast.makeText(getContext(), "No Record Found", Toast.LENGTH_LONG);
  toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
  </code></pre>
  
  <p><strong>ImagePagerAdapter.java</strong></p>
  
  <pre><code>public class ImagePagerAdapter extends PagerAdapter {
  
  private Context mContext;
  private ImageLoader mImageLoader; // It's use for downloading the image from server
  private ArrayList&lt;SlideShowData&gt; slideShowImages; // In this I have all the detail of the image from  API
  
  public ImagePagerAdapter(Context context, ArrayList&lt;SlideShowData&gt; mSlideShowData) {
      mContext = context;
      slideShowImages = mSlideShowData;
      mImageLoader = new ImageLoader(mContext);
  
  }
  
  @Override
  public int getItemPosition(Object object) {
       return POSITION_NONE;
  }
  
  @Override
  public int getCount() {
      return slideShowImages.size();
  }
  
  @Override
  public boolean isViewFromObject(View view, Object object) {
      return view == ((ImageView) object);
  }
  
  
  
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
  
      ImageView imageViewSlideShow = new ImageView(mContext);
      int padding = mContext.getResources().getDimensionPixelSize(R.dimen.padding_medium);
      imageViewSlideShow.setPadding(padding, padding, padding, padding);
      imageViewSlideShow.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      mImageLoader.DisplayImage(ServiceURLs.URL+"/photos/"+slideShowImages.get(position).photo_name, R.drawable.loading, imageViewSlideShow);
      ((ViewPager) container).addView(imageViewSlideShow, 0);
      return imageViewSlideShow;
  }
  
  @Override
  public void destroyItem(ViewGroup container, int position, Object object) {
      ((ViewPager) container).removeView((ImageView) object);
  
  }
  
  @Override
  public void notifyDataSetChanged() {
          super.notifyDataSetChanged();
  }
  
  }
  </code></pre>
  
  <p>For solution , I tried :</p>
  
  <pre><code>@Override
  public int getItemPosition(Object object) {
       return POSITION_NONE;
  }
  
  //And
  
  slideShowPager.getAdapter().notifyDataSetChanged();
  </code></pre>
  
  <p>the solution I got from stackoverflow but couldn't work.</p>
  
  <p><strong>what i need to changes for working</strong> ?</p>
  
  <p><strong>Solution</strong></p>
  
  <p><code>earlier I am Passing the ArrayList But this time String Array **(working )** Really I don't know whats the problem with the ArrayList</code></p>