我将我的图像保存在assets文件夹中并尝试显示它们.我试过很多方面,但仍然无法显示图像.在logcat中它没有显示任何错误.
关于这个请帮帮我..........
AssetManager mngr = mContext.getResources().getAssets();
is = mngr.open("test3.png");
bitmap = BitmapFactory.decodeStream(is);
Uri uriSavedImage=Uri.fromFile(pictures_directory);
((ImageView) view.findViewById(R.id.imageView1)).setImageBitmap(bitmap);
Run Code Online (Sandbox Code Playgroud)
Lal*_*ani 28
您可以使用AssetManager它的open()方法获取InputStream ,然后使用decodeStream()方法BitmapFactory获取Bitmap.
private Bitmap getBitmapFromAsset(String strName)
{
AssetManager assetManager = getAssets();
InputStream istr = null;
try {
istr = assetManager.open(strName);
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(istr);
return bitmap;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18154 次 |
| 最近记录: |