【发布时间】:2014-05-10 10:42:09
【问题描述】:
我的资产文件夹中有一个 .png 文件,当我点击屏幕时,我试图让该图像显示在屏幕上。
InputStream open = null;
try{
open = asset.open("ic_launcher.png");
Bitmap bitmap = BitmapFactory.decodeStream(open);
ImageView image = (ImageView)findViewById(R.id.imageView1);
image.setImageBitmap(bitmap);
}catch(Exception e){
e.printStackTrace();
}
finally{
if(open != null){
try{
open.close();
}catch(IOException e){
e.printStackTrace();
}
}
}
但我不断收到FileNotFoundException,不知道为什么。
【问题讨论】:
-
ic_launcher.png到底在哪里? -
我的项目的
assets文件夹。 -
是 ic_launcher.png 存储在 assets.put 你的完整代码.asset 的初始化
-
project_name/assets/ic_launcher.png?