android - viewpager OutOfMemoryError
<p>I have a problem. I want to get image URL from JSON and setting to viewpager. I tried it with <code>drawable</code> folder, but large images  are causing problems. If the image would be small, then I would not have a problem. How can I get large images? I benefited from this article : <a href="http://manishkpr.webheavens.com/android-viewpager-as-image-slide-gallery-swipe-gallery/" rel="nofollow">enter link description here</a></p>

<p>GalleryActivity</p>

<pre><code>@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_gallery);
    ViewPager viewPager = (ViewPager)findViewById(R.id.viewpa);
    GalleryAdapter ga = new GalleryAdapter(this);
    viewPager.setAdapter(ga);
}
</code></pre>

<p>Gallery Adapter (extending PagerAdapter)</p>

<pre><code>Context context;
private int[] GalImages = new int[] {
        R.drawable.one,
        R.drawable.two,
        R.drawable.three
};
GalleryAdapter(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]);// error on this line when large image
    ((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>And logcat outputs</p>

<pre><code>java.lang.OutOfMemoryError at android.graphics.BitmapFactory
...
</code></pre>