gpt4 book ai didi

android - getQuantityString 没有用值替换格式

转载 作者:IT老高 更新时间:2023-10-28 21:39:07 26 4
gpt4 key购买 nike

我想使用复数资源来生成像 "9" 这样的带引号的数字。

在我的 plurals.xml 中:

<plurals name="posts">
<item quantity="other">\"%dd\"<\item>
</plurals>

代码:

String text = res.getQuantityString(R.plurals.posts, meUser.postCount); 

postCount为9时,为什么text"%dd"而不是"9"

最佳答案

来自 the Android docs:

When using the getQuantityString() method, you need to pass the count twice if your string includes string formatting with a number. For example, for the string %d songs found, the first count parameter selects the appropriate plural string and the second count parameter is inserted into the %d placeholder. If your plural strings do not include string formatting, you don't need to pass the third parameter to getQuantityString.

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

关于android - getQuantityString 没有用值替换格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16702092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com