我運行這個程序它是正常顯示,但當我點擊這個圖像或滾動這個圖像它崩潰了。請幫助我!Android上的圖像畫廊3
我的代碼在這裏:enter link description here
我的錯誤:
05-18 14:18:56.064: E/AndroidRuntime(1375): FATAL EXCEPTION: main
05-18 14:18:56.064: E/AndroidRuntime(1375): java.lang.OutOfMemoryError
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.content.res.Resources.loadDrawable(Resources.java:1965)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.content.res.Resources.getDrawable(Resources.java:660)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.ImageView.resolveUri(ImageView.java:616)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.ImageView.setImageResource(ImageView.java:349)
05-18 14:18:56.064: E/AndroidRuntime(1375): at com.example.gallerycookbook.GalleryImageAdapter.getView(GalleryImageAdapter.java:47)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.makeAndAddView(Gallery.java:865)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.fillToGalleryRightLtr(Gallery.java:819)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.fillToGalleryRight(Gallery.java:763)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.trackMotionScroll(Gallery.java:393)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.onScroll(Gallery.java:1043)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.GestureDetector.onTouchEvent(GestureDetector.java:572)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.widget.Gallery.onTouchEvent(Gallery.java:958)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.View.dispatchTouchEvent(View.java:7246)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2168)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1903)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
05-18 14:18:56.064: E/AndroidRuntime(1375): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)
05-18 14:18:56.064: E/AndroidRuntime(1375): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.app.Activity.dispatchTouchEvent(Activity.java:2410)
05-18 14:18:56.064: E/AndroidRuntime(1375): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.View.dispatchPointerEvent(View.java:7426)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)
05-18 14:18:56.064: E/AndroidRuntime(1375): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363)
感謝您@Andrey馬爾可夫 – user3623959
您的歡迎:) –