Android在Gallery中显示多个图像

时间:2013-11-07 10:08:57

标签: android android-imageview android-gallery android-memory

我正在尝试从图库中显示多个图像。为此,我使用MultipleImagePick库从Gallery中选择多个图像。我的问题是,当在图像视图中显示所选图像时,我得到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);
}

0 个答案:

没有答案
相关问题