例如,我有一些数字:
Strig num = resources.getResourceName(2130903218);
,然后返回
Unable to find resource ID #0x7f0300b2
如何从2130903218 -> #0x7f0300b2
得到。是哪种格式?我可以从#0x7f0300b2 -> 2130903218
我正在写一些文档,我需要知道这是如何转换的
0x7f0300b2 = 2130903218, getResourceName将返回资源名称。例句:
<resources>
<string name="hello_world">Hello world!</string></resources>
和resources.getResourceName(R.string.hello_world)
将返回一个形式为"package:string/hello_world"的字符串。您应该看到参考文档
没什么特别的,当抛出异常时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
(grep代码)