开发者

Constants for resource types in Android

开发者 https://www.devze.com 2023-01-08 07:31 出处:网络
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 ha

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

精彩评论

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