求助:从一个XML文件中获取字符串,内容大概就是262626这样。现在需要将字符串转换到 MB (/1024) 形式。但是不能转换int或者长整型。我的测试代码:String size = parser.getValue(e, parser.KEY_FileSizeInByte);
Log.i("menuItems",size);
try {
int s = Integer.parseInt(size);
Log.i("s", getString(s));
}
catch (Exception e1) {
Log.i("error", e1.getMessage());
}我还测试了:Integer.valueOf(str);得到的错误:04-15 23:06:17.652: I/menuItems(6819): 97035
04-15 23:06:17.652: W/ResourceType(6819): No package identifier when getting value for resource number 0x00017b0b
04-15 23:06:17.652: I/error(6819): String resource ID #0x17b0b
04-15 23:06:17.692: I/menuItems(6819): 2957
04-15 23:06:17.692: W/ResourceType(6819): No package identifier when getting value for resource number 0x00000b8d
04-15 23:06:17.692: I/error(6819): String resource ID #0xb8d
04-15 23:06:17.692: I/menuItems(6819): 559711
04-15 23:06:17.692: W/ResourceType(6819): No package identifier when getting value for resource number 0x00088a5f
04-15 23:06:17.692: I/error(6819): String resource ID #0x88a5f
04-15 23:06:17.692: I/menuItems(6819): 153651
04-15 23:06:17.692: W/ResourceType(6819): No package identifier when getting value for resource number 0x00025833
04-15 23:06:17.692: I/error(6819): String resource ID #0x25833
04-15 23:06:17.692: I/menuItems(6819): 1733630
04-15 23:06:17.692: W/ResourceType(6819): No package identifier when getting value for resource number 0x001a73fe
2 回答
拉风的咖菲猫
TA贡献1995条经验 获得超2个赞
是这里出的问题:
Log.i("s", getString(s));
这是使用给定标识符获取资源,你只需要这样就可以:
Log.i("s", String.valueOf(s));
添加回答
举报
0/150
提交
取消