我试图放置多个图像使模拟器崩溃时出现问题。一个解决方案是这个 您将图像放在Assets文件夹而不是Drawable文件夹中,但我不知道如何返回此方法并将其作为ImageView的src图像
public static Drawable getAssetImage(Context context, String filename) throws IOException {
AssetManager assets = context.getResources().getAssets();
InputStream buffer = new BufferedInputStream((assets.open("drawable/" + filename + ".png")));
Bitmap bitmap = BitmapFactory.decodeStream(buffer);
return new BitmapDrawable(bitmap);
}