安卓:从获取资源对象的所有可绘制资源 [英] Android: retrieving all Drawable resources from Resources object

查看:170
本文介绍了安卓:从获取资源对象的所有可绘制资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid项目,我想通过绘制对象资源的整个集合循环。通常情况下,你只能通过它的ID使用类似检索特定的资源:

In my Android project, I want to loop through the entire collection of Drawable resources. Normally, you can only retrieve a specific resource via its ID using something like:

InputStream is = Resources.getSystem().openRawResource(resourceId)

不过,我想所有的绘制对象的资源,我的不会了解自己的ID提前。是否有收集我可以遍历或者一个办法让我的项目资源ID的特定资源的列表?

However, I want to get all Drawable resources where I won't know their ID's beforehand. Is there a collection I can loop through or perhaps a way to get the list of resource ID's given the resources in my project?

或者,有没有办法,我在Java中,从 R.drawable 静态类提取所有属性值?

Or, is there a way for me in Java to extract all property values from the R.drawable static class?

推荐答案

如果你发现自己想要做到这一点,你可能滥用资源系统。看看资产和<一href="http://developer.android.com/reference/android/content/res/AssetManager.html"><$c$c>AssetManager如果你想遍历文件包含在你的apk文件。

If you find yourself wanting to do this you're probably misusing the resource system. Take a look at assets and AssetManager if you want to iterate over files included in your .apk.

这篇关于安卓:从获取资源对象的所有可绘制资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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