如何在有​​资产的文件夹名称图像阵列获得ID图像阵列 [英] how to get array of ID image when have array of name image in assets folder

查看:251
本文介绍了如何在有​​资产的文件夹名称图像阵列获得ID图像阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用AssetManager然后我在文件夹资产/ testAssets / img1.jpg,... img50.jpg名称的图像阵列。在这里,code:

最后AssetManager ASMR = getAssets();
 的String [] =文件列表asmr.list(testAssets);

我需要从阵列得到所有ID图片使用此code其他1功能:

 `可绘制D = getResources()getDrawable(图像的ID有索引i);`

我能获得ID用绘制对象?!如果我不能,我可以用任何东西来使用绘制对象,我必须用可绘做我的应用程序! TKS这么多....


解决方案

 可绘制D = Drawable.createFromStream(getAssets()。打开(文件夹/ my_image.png),NULL) ;

I use AssetManager then i have array of name images in folder "assets/testAssets/img1.jpg,...img50.jpg". Here code:

final AssetManager asmr = getAssets(); String[] filelist = asmr.list("testAssets");

I need get all ID images from that array to use this code from 1 other function:

`Drawable d = getResources().getDrawable(ID of image have index i);`

Can i get ID to use "Drawable" ?! If i can't, can i use any thing to use "Drawable", i must use "Drawable" to do my application! Tks so much....

解决方案

Drawable d = Drawable.createFromStream(getAssets().open("folder/my_image.png"), null);

这篇关于如何在有​​资产的文件夹名称图像阵列获得ID图像阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆