10

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

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

4

1 回答 1

0

它似乎是硬编码的:

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

于 2011-03-01T10:25:35.613 回答