我试图在参考资料中使用getQuantityString方法来检索基于android开发人员指南的数量字符串(复数)数量字符串(复数)
我得到的错误是
Error:(604) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
Error:(604) Found tag </item> where </plurals> is expected
Run Code Online (Sandbox Code Playgroud)
当我设置复数如下
<plurals name="productCount">
<item quantity="one" formatted="true">%1$d of %2$d product</item>
<item quantity="other" formatted="true">%1$d of %2$d products</item>
</plurals>
Run Code Online (Sandbox Code Playgroud)
并尝试阅读如下
productIndexCountText.setText(getResources().getQuantityString(R.plurals.productCount, position, size));
Run Code Online (Sandbox Code Playgroud)
一种解决方法是将字符串分解为仅对字符串的最后部分使用复数并连接这两部分.但我试图尽可能避免这样做.