我正在开发一个 Android 应用程序来将一些图像加载到模拟器,但它失败并出现以下错误:
11-07 19:38:51.596: E/dalvikvm-heap(322): 73670400-byte external
allocation too large for this process.
11-07 19:38:51.596: E/GraphicsJNI(322): VM won't let us allocate
73670400 bytes
11-07 19:38:51.596: D/AndroidRuntime(322): Shutting down VM
11-07 19:38:51.616: W/dalvikvm(322): threadid=1: thread exiting with
uncaught exception (group=0x4001d800)
11-07 19:38:51.926: E/AndroidRuntime(322): FATAL EXCEPTION: main
11-07 19:38:51.926: E/AndroidRuntime(322): java.lang.OutOfMemoryError:
bitmap size exceeds VM budget
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.nativeCreate(Native Method)
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.createBitmap(Bitmap.java:468)
11-07 19:38:51.926: E/AndroidRuntime(322): at
android.graphics.Bitmap.createBitmap(Bitmap.java:435)
我的 Java 代码在下面发生错误的地方。我曾经System.out.println
调试过这个问题。
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
System.out.println("11");
ImageView imageView = new ImageView(context);
System.out.println("12");
imageView.setImageResource(imageIDs[position]);
System.out.println("13");
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
System.out.println("14");
imageView.setLayoutParams(new Gallery.LayoutParams(150, 220));
System.out.println("15");
imageView.setBackgroundResource(itemBackGround);
System.out.println("16");
return imageView;
}
如果您能提供帮助,我将不胜感激。谢谢。