0

我正在尝试在此链接上实现在“Imageswitcher View”下编写的代码

http://mobiforge.com/designing/story/understanding-user-interface-android-part-3-more-views

当我单击第一个图像时,它会放大,但在单击第二个图像时,代码会崩溃,但如果我从第二个图像开始,它不会崩溃。

Logcat 说

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)
4

0 回答 0