title: Why does my ViewPager crash?
body: <p>I have 25 pictures in my project and I have a <code>Button</code> in my first <code>Activity</code>. When click this <code>Button</code> I want my app show the first pic of 25, then I want to swipe to change my pics.</p>
  
  <p>This is my <code>PagerAdapter</code>:</p>
  
  <pre><code>public class ImageAdapter extends PagerAdapter {
      Context context;
      private int[] GalImages = new int[] {
              R.drawable.one,
              R.drawable.two,
              R.drawable.three
      };
  
      ImageAdapter(Context context) {
          this.context = context;
      }
  
      @Override
      public int getCount() {
          return GalImages.length;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
          return view == ((ImageView) object);
      }
  
      @Override
      public Object instantiateItem(ViewGroup container, int position) {
          ImageView imageView = new ImageView(context);
          int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium);
          imageView.setPadding(padding, padding, padding, padding);
          imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
          imageView.setImageResource(GalImages[position]);
          ((ViewPager) container).addView(imageView, 0);
          return imageView;
      }
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object object) {
          ((ViewPager) container).removeView((ImageView) object);
      }
  }
  </code></pre>
  
  <p>Then create the xml file and add the <code>ViewPager</code> in layout</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".MainActivity" &gt;
  
      &lt;android.support.v4.view.ViewPager
          android:id="@+id/view_pager"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Then create main <code>Activity</code> and create the instance of <code>ViewPager</code></p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
          ImageAdapter adapter = new ImageAdapter(this);
          viewPager.setAdapter(adapter);
      }
  
  }
  </code></pre>
  
  <p>Everything is good, but when my app arrive to 20th pic of my 25 pics this error appears:</p>
  
  <blockquote>
    <p>unfortunately, gallery 3 has stopped</p>
  </blockquote>
  
  <p>please read here : </p>
  
  <p>i find out some pics are very big so this error appears , when i delete them app is good now....... 
  is not anyway else ??
  i do not want delete my pics </p>