如题所说,无法打开asset文件夹中的图片:
public static final String CONTENT_URI = "file:///android:asset/";
Uri tmp = Uri.parse(CONTENT_URI + s);
holder.image.setImageURI(tmp);
用了很多语法,但是都检测不到asset 。总是报resolveUri errors 。
s是一个字符串,比如hears.png,位于asset文件夹中。
InputStream in = getResources().getAssets().open(fileName);
Bitmap b = BitmpaFactory.decodeStream(in);
imageView.setImage(b);
android里取asset里的文件是用AssetManager这个API的
这样就可以从asset中获取图片了:
yourImageView.setImageBitmap(BitmapFactory.decodeStream(activity.getResources().getAssets().open("whateverResorce.png")));