【发布时间】:2014-09-11 19:30:08
【问题描述】:
我在 android studio 中的 App 下创建了一个资产文件夹目录,其中包含 Build、Libs 和 Src,我在其中分别放置了带有图像的文件夹。我有一个问题,我无法在该文件名或路径中找到该文件,但我知道它是正确的,请告诉我该怎么做,因为我很难过。该文件位于此目录 assets/profileicon/26.png 中,数字由 profileIconTag 确定(在本例中为 26)现在我为 .open() 做正确的路径名了吗?
AssetManager assetManager = getAssets();
InputStream istr = null;
try {
istr = assetManager.open("/profileicon/" + profileIconTag + ".png");
} catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(istr);
profileIcon.setImageBitmap(bitmap);
【问题讨论】: