Ral*_*kum 6 lint android-resources
我的Lintcheck抱怨我的字符串资源.
潜在的Plurals res/values/strings.xml格式化%d后跟单词("Pers"):这应该是复数而不是字符串
此资源以前是一个,但我将其更改为正常的字符串,如:
<string name="plain_string">%d Pers</string>
Run Code Online (Sandbox Code Playgroud)
我会理解一个警告,但是错误?我怎么解决这个问题?
小智 18
字符串转换为像descriped复数这里:
<plurals name="plain_string">
<item quantity="one">%d Pers</item>
<item quantity="other">%d Pers</item>
</plurals>
Run Code Online (Sandbox Code Playgroud)
在您的代码中,您必须替换
getContext().getString(R.string.plain_string, pers)
Run Code Online (Sandbox Code Playgroud)
通过
getContext().getResources().getQuantityString(R.plurals.plain_string, pers)
Run Code Online (Sandbox Code Playgroud)
或者像这样禁止警告:
<string name="plain_string" tools:ignore="PluralsCandidate">%d Pers</string>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1233 次 |
| 最近记录: |