我有一个包含 6 个 ViewFlippers 的 fragment ,每个 flippers 至少包含 10 个 ImageViews。我试图加载所有图像并将它们放在 ImageViews 中,但受限的内存不允许我这样做。每次我运行该应用程序时都会发生此异常。
当我减少我的应用程序运行的图像数量时,但这不是解决方案。
那么这样做的最佳方法是什么?
这是我到目前为止尝试过的:
for(int i=0; i<flippers.length; i++) {
for (int j = 0; j < names.length; j++) {
int imageResource = getResources().getIdentifier(names[j], "drawable", rootView.getContext().getPackageName());
ImageView imageView = new ImageView(rootView.getContext());
imageView.setImageResource(imageResource);
flippers[i].addView(imageView);
}
}
26546-26546/com.azad E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.azad, PID: 26546 java.lang.OutOfMemoryError
最佳答案
关于android - 将多个图像添加到 ViewFlipper 中的 ImageViews 时出现“OutOfMemoryError”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28795082/