我从XML读取。在ImageView中添加本地图像
<movie>
<id>1</id>
<title>Fast</title>
<background>assets://icon/photography1</background>
</movie>
现在我已经得到了类Movie
。
如何在我的ImageView中添加assets://icon/photography1
?
我从XML读取。在ImageView中添加本地图像
<movie>
<id>1</id>
<title>Fast</title>
<background>assets://icon/photography1</background>
</movie>
现在我已经得到了类Movie
。
如何在我的ImageView中添加assets://icon/photography1
?
您可以通过android中的java代码以编程方式将图像从集合添加到图像视图。代码如下:
ImageView image = (ImageView) findViewById(R.id.imageView1);
AssetManager assetManager = getAssets();
InputStream istr;
try {
istr = assetManager.open("vishal.jpg");
Bitmap bitmap = BitmapFactory.decodeStream(istr);
image.setImageBitmap(bitmap);
istr.close();
} catch (IOException e) {
e.printStackTrace();
}
你可以用java代码来完成它。 – Amy
看到http://stackoverflow.com/questions/4820816/how-to-get-uri-from-an-asset-file – Harry
我发现一个开源可以做到这一点.https://github.com/nostra13/Android -Universal-Image-Loader – CoolEgos