我的项目在 strings.xml 中使用类似于以下的字符串声明:
<string name="file_size">File Size (%1$dMB)</string>
在我的代码中,我正在使用
getResources().getString(R.string.file_size, getFileSize());
其中 getFileSize() 返回一个 long。 Lint 给我这个错误:
“file_size 中格式化参数 '#1' 的参数类型错误:转换为 'd',接收到长(方法调用中的参数 #2)”
这是怎么回事? Android 文档说:
最佳答案
看起来像是 lint 规则中的错误。查看 StringFormatDetector
的来源:
// Numeric: integer and floats in various formats
case 'x':
case 'X':
case 'd':
case 'o':
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
case 'a':
case 'A':
valid = type == Integer.TYPE
|| type == Float.TYPE;
break;
关于java - 在 strings.xml 中使用长值时,Lint 给出 "Wrong format type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23960019/