开发者

Constants for resource types in Android

Are there constants for the various resource types (ie: "drawable") in Android?

I want to code some conditional logic based on the return value of getResourceTypeName and I would prefer to avoid hardcoding the resource types.

Example:

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

(I can create my own c开发者_运维技巧onstants, obviously, but I would prefer to use system constants to ensure upward compatibility)


It seems to be hardcoded:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜