Issue
I am developing an android game app and I have more then 150 images inside my app! I want to put all images which exist in drawable package in a ArrayList. I have this code
InputStream ips = getAssets().open("Arrow001.jpg");
Drawable d = Drawable.createFromStream(ips, null);
questionImageView.setImageDrawable(d);
but i don't want to add them one by one in myArray and i want to use a loop for generate images in arrayList when i run my app!
Thanks for your help
Solution
You can get array of all assets files on root assets folder by calling
String[] list = getAssets().list("")
In our case you can write code like below.
for (String assetPath : getAssets().list("")) {
InputStream ips = getAssets().open(assetPath);
//yours code
}
Answered By - adrbtk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.