Android中资源类型的常量

hpi*_*que 10 resources android constants hardcode

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
Run Code Online (Sandbox Code Playgroud)

(显然,我可以创建自己的常量,但我更喜欢使用系统常量来确保向上兼容性)

paw*_*eba 0

它似乎是硬编码的:

http://codesearch.google.com/codesearch?q= \%22drawable\%22+\%22xml\%22&exact_package=git://android.git.kernel.org/platform/frameworks/base.git