Bitmap size exceed VM budget while using gallery and imageviews
<p>I am trying to implement the code written under "Imageswitcher View" on this link </p>

<p><a href="http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views" rel="nofollow">http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views</a></p>

<p>When I click first Image it enlarges but on clicking the second image the code crashes but if I start from the second image it does not crash .</p>

<p>Logcat says</p>

<pre><code>08-08 22:15:08.655: E/AndroidRuntime(1349): FATAL EXCEPTION: main
08-08 22:15:08.655: E/AndroidRuntime(1349): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.Bitmap.nativeCreate(Native Method)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.Bitmap.createBitmap(Bitmap.java:477)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.Bitmap.createBitmap(Bitmap.java:444)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:349)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:498)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:473)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.content.res.Resources.getDrawable(Resources.java:581)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.widget.ImageView.resolveUri(ImageView.java:501)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.widget.ImageView.setImageResource(ImageView.java:280)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.k.TestingActivity$1.onItemClick(TestingActivity.java:47)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.widget.AdapterView.performItemClick(AdapterView.java:284)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.widget.Gallery.onSingleTapUp(Gallery.java:867)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.GestureDetector.onTouchEvent(GestureDetector.java:557)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.widget.Gallery.onTouchEvent(Gallery.java:842)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.View.dispatchTouchEvent(View.java:3885)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.os.Looper.loop(Looper.java:123)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at java.lang.reflect.Method.invokeNative(Native Method)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at java.lang.reflect.Method.invoke(Method.java:507)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-08 22:15:08.655: E/AndroidRuntime(1349):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
