【发布时间】:2011-08-23 22:51:57
【问题描述】:
我正在使用 ViewFlipper 显示来自 db 的一些图像。 然后我将 blob 值转换为 ArrayList,将每个字节数组转换为位图。
然后我将这些每个位图设置为 ViewFlipper 的每个 Imageview。 如果图像数量低于 10,则它工作正常。但是如果它超过 10,那么它会突然捕获一个 Exception : OutOfMemoryException : 位图大小超出 VM 预算。
当我使用 BitmapFactory.Options 的 inSampleSize 时,它工作正常。但我想显示具有实际高度和宽度的图像。我怎样才能毫无例外地做到这一点?
我的代码是:
ViewFlipper vfImage = (ViewFlipper)findViewById(R.id.vfImage);
for(Photos objPhotos :arPhotos)
{
byte[] btImages = null;
Bitmap bitmapImage = null;
btImages = objPhotos.getImage();
ImageView imgPhoto= new ImageView(this);
bitmapImage = BitmapFactory.decodeByteArray(btImages, 0, btImages.length);
imgPhoto.setImageBitmap(bitmapImage);
vfImage.addView(imgPhoto);
}
vfImage.startFlipping();
请帮帮我.. 谢谢...
【问题讨论】:
标签: android bitmap out-of-memory viewflipper