【发布时间】:2013-04-06 06:44:03
【问题描述】:
我正在尝试使用我在整个 stackoverflow 的多个帖子中看到的这段代码
public static Bitmap loadBitmap(Context context, String filename) throws IOException {
AssetManager assets = context.getResources().getAssets();
InputStream buf = new BufferedInputStream((assets.open("drawable/" + filename)));
Bitmap bitmap = BitmapFactory.decodeStream(buf);
return bitmap;
}
但我收到“FileNotFoundException:drawable/filename”。我肯定有一个名称为我试图加载到可绘制文件夹中的文件。有任何想法吗?我尝试过使用和不使用文件扩展名,尝试将文件放入每个文件夹并尝试多个手机/模拟器。
【问题讨论】:
-
尝试新的 BufferedInputStream((assets.open(.getResources().getDrawable(R.drawble.img)));
-
您的图片名称是否包含大写字母?