机器人 - 获取绘制资源列表 [英] Android - Getting a list of drawable resource

查看:87
本文介绍了机器人 - 获取绘制资源列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的,你可以访问资源与语法如R ..

In android you can access a resource with syntax like R..

我想要做的就是要达到一组图片有命名约定。

what I want to do is to reach a set of images has naming convention.

例如我在绘制4个文件的名称:

for example I have 4 files in drawable with the names :

draw_1_.jpg

draw_1_.jpg

我怎样才能绘制图像列表列出。

how can I get the list of drawable images to List ..

这是因为,我想打一个幻灯片。

This is because, I want to make a slide show.

THX

推荐答案

好了,如果你知道图片的后缀,您可以通过请求标识的绘制<一个href="http://developer.android.com/reference/android/content/res/Resources.html#getIdentifier%28java.lang.String,%20java.lang.String,%20java.lang.String%29"相对=nofollow> getResources()。则getIdentifier(...)的,然后使用识别符得到被拉伸。所以,如果你知道你有多少图像有,那么你就可以创建一个循环,每一个可绘制的保存在列表中。只是考虑到这样的查找是相对昂贵的。

well, if you know the suffix of the images, you can request the identifier for a drawable by getResources().getIdentifier(...) and then using the identifier get the drawable. So if you know how many images you have, then you can create a loop and store each of the drawables in a list. Just take into account that such a lookup is relatively expensive.

这篇关于机器人 - 获取绘制资源列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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