getQuantityString不用值替换格式

Ros*_*one 39 android

我想使用复数资源来生成一个引用的数字"9".

在我的plurals.xml:

<plurals name="posts">
  <item quantity="other">\"%dd\"<\item>
</plurals>
Run Code Online (Sandbox Code Playgroud)

代码:

String text = res.getQuantityString(R.plurals.posts, meUser.postCount); 
Run Code Online (Sandbox Code Playgroud)

当它postCount是9时,为什么text结果是"%dd"和不"9"

Ros*_*one 110

来自Android文档:

使用该getQuantityString()方法时,如果字符串包含带数字的字符串格式,则需要将计数传递两次.例如,对于%d找到的字符串歌曲,第一个计数参数选择适当的复数字符串,第二个计数参数插入%d占位符.如果您的复数字符串不包含字符串格式,则无需将第三个参数传递给getQuantityString.

res.getQuantityString(R.plurals.numberOfSongsAvailable, count, count);