Android如何转换资源id号?

Android如何转换资源id号?,android,Android,例如,我有一些数字,如: Strig num = resources.getResourceName(2130903218); 我回来了: Unable to find resource ID #0x7f0300b2 我是如何从2130903218->#0x7f0300b2获得的。那是哪种格式?我可以从#0x7f0300b2->2130903218 我正在写一些文档,我需要知道这是如何转换的。没有什么特别的,当抛出异常时,ID打印为十六进制字符串 1013 public void More

例如,我有一些数字,如:

Strig num = resources.getResourceName(2130903218);
我回来了:

Unable to find resource ID #0x7f0300b2
我是如何从
2130903218->#0x7f0300b2
获得的。那是哪种格式?我可以从
#0x7f0300b2->2130903218


我正在写一些文档,我需要知道这是如何转换的。

没有什么特别的,当抛出异常时,ID打印为十六进制字符串

1013 public void More ...getValue(int id, TypedValue outValue, boolean resolveRefs)
1014            throws NotFoundException {
1015        boolean found = mAssets.getResourceValue(id, 0, outValue, resolveRefs);
1016        if (found) {
1017            return;
1018        }
1019        throw new NotFoundException("Resource ID #0x"
1020                                    + Integer.toHexString(id));
1021 }

因此,只需使用
Integer.toHexString
()

<0x7f0300b2=2130903218,getResourceName将返回资源的名称。 e、 g:


你好,世界!
resources.getResourceName(R.string.hello_-world)
将返回一个格式为“package:string/hello_-world”的字符串。您应该看到。

Um,为什么您会有
resources.getResourceName(2130903218)
<resources>
<string name="hello_world">Hello world!</string></resources>