简体   繁体   中英

Cannot Open Image in assets folder for Android App

Just like the title says, i can't seem to get the images in my assets folder to open up.

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

I have tried a bunch of different syntax's, and I can't seem to get the asset to be detected. Keep getting resolveUri errors about it not finding the files.

s is a string such as hears.png which is indeed in the assets folder.

This is what you need to get images from asset

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

Regards!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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