我從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