簡體   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