Android 中是否有各种资源类型(即:“drawable”)的常量?
我想根据 getResourceTypeName 的返回值编写一些条件逻辑代码我更愿意避免对资源类型进行硬编码。
例子:
final String type = context.getResources().getResourceTypeName(resid);
if ("drawable".equalsIgnoreCase(type)) {
// Something
} else if ("xml".equalsIgnoreCase(type)) {
// Something else
}
// TODO: Replace above strings with system constants
(显然,我可以创建自己的常量,但我更愿意使用系统常量来确保向上兼容)
最佳答案
它似乎是硬编码的:
http://codesearch.google.com/codesearch?q=\%22drawable\%22+\%22xml\%22&exact_package=git://android.git.kernel.org/platform/frameworks/base.git
关于android - Android 中资源类型的常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3276583/