0
對不起,我的英文。 在其應用程序中,我使用Android的圖像滑塊https://github.com/daimajia/AndroidImageSliderAndroidImageSlider:createBitmap錯誤和OutOfMemoryError
下面的代碼:
SliderLayout exPhoto = (SliderLayout) findViewById(R.id.ex_img);
exPhoto.removeAllSliders();
for (String url : object.getImages()) {
try {
Log.e("test", "load textSliderView");
TextSliderView textSliderView = new TextSliderView(this);
textSliderView
.image(url)
.setScaleType(BaseSliderView.ScaleType.CenterCrop);
exPhoto.addSlider(textSliderView);
}catch (OutOfMemoryError e){
Log.e("test", "exception textSliderView");
}
}
exPhoto.stopAutoCycle();
這裏的錯誤:
05-11 15:41:08.855 5873-6125/ru.mabee.justme_android.app E/Bitmap? createBitmap error!
05-11 15:41:09.335 5873-6126/ru.mabee.justme_android.app E/dalvikvm? GC_FOR_ALLOC freed 1674K, 18% free 53549K/64995K, paused 4ms+22ms
05-11 15:41:09.445 5873-5873/ru.mabee.justme_android.app E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:492)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:360)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
at android.content.res.Resources.loadDrawable(Resources.java:1937)
at android.content.res.Resources.getDrawable(Resources.java:664)
at android.widget.ImageView.resolveUri(ImageView.java:542)
at android.widget.ImageView.setImageResource(ImageView.java:315)
at com.squareup.picasso.ImageViewAction.error(ImageViewAction.java:61)
at com.squareup.picasso.Picasso.deliverAction(Picasso.java:563)
at com.squareup.picasso.Picasso.complete(Picasso.java:510)
at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:117)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
at dalvik.system.NativeStart.main(Native Method)
E/dalvikvm? GC_FOR_ALLOC freed 395K, 17% free 54464K/64995K, paused 2ms+18ms
E/dalvikvm? GC_BEFORE_OOM freed 105K, 17% free 54358K/64995K, paused 170ms
E/dalvikvm-heap? Out of memory on a 983056-byte allocation.
我所能做的是將路徑傳遞到圖像
textSliderView
.image(url)
.setScaleType(BaseSliderView.ScaleType.CenterCrop);
我不直接使用Bitmaps
此錯誤發生在低位手機和20次更新後。
請幫幫