繁体   English   中英

无法在Android App的资源文件夹中打开图像

[英]Cannot Open Image in assets folder for Android App

就像标题中所说的那样,我似乎无法在我的资产文件夹中打开图像。

public static final String CONTENT_URI = "file:///android:asset/";
Uri tmp = Uri.parse(CONTENT_URI + s);
holder.image.setImageURI(tmp);

我尝试了多种不同的语法,但似乎无法检测到资产。 不断收到关于找不到文件的resolveUri错误。

s是一个字符串,例如hears.png ,它的确存在于资产文件夹中。

这就是从资产中获取图像所需要的

yourImageView.setImageBitmap(BitmapFactory.decodeStream(activity.getResources().getAssets().open("whateverResorce.png")));

问候!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM