0

我正在尝试显示画廊中的多张图片。为此,我使用MultipleImagePick库从图库中选择多个图像。我的问题是,在图像视图中显示所选图像时,出现 java.lang.OutOfMemoryError

这是日志

11-07 15:20:23.035: E/AndroidRuntime(2679): FATAL EXCEPTION: main
11-07 15:20:23.035: E/AndroidRuntime(2679): java.lang.OutOfMemoryError
11-07 15:20:23.035: E/AndroidRuntime(2679):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
11-07 15:20:23.035: E/AndroidRuntime(2679):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:650)
11-07 15:20:23.035: E/AndroidRuntime(2679):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:389)
11-07 15:20:23.035: E/AndroidRuntime(2679):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:449)

我正在使用下面的代码在 imageView 中显示图像

    Bitmap bitmapOriginal = null;
    Bitmap bitmapsimplesize = null;
    ImageView imageView;
    File imageFile;

for (String string : all_path) {
    imageView = new ImageView(this);
        imageFile = new File(string); 
        if(imageFile.exists()){
            bitmapOriginal = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
            bitmapsimplesize = Bitmap.createScaledBitmap(bitmapOriginal,200, 200, true);
            bitmapOriginal.recycle();
            imageView.setPadding(10, 10, 10, 10);
            imageView.setImageBitmap(bitmapsimplesize);
        } else {
            Log.d("@@##", "image not exist");
        }
        imageHoler.addView(imageView);
}
4

0 回答 0