我正在尝试在我最新的 Android 项目(SDK9)中使用复数。它总是以 ResourcesNotFoundException 结束。但是资源在那里 - 绝对是:
这是我的 strings.xml 的那一部分:
<plurals name="count_files">
<item quantity="one">%d file</item>
<item quantity="other">%d files</item>
<item quantity="zero">%d files</item>
</plurals>
<plurals name="count_folders">
<item quantity="one">%d folder</item>
<item quantity="other">%d folders</item>
<item quantity="zero">%d folders</item>
</plurals>
这是使用它的那部分:
textView.setText(
getResources().getQuantityString(R.plurals.count_folders, countfolders, countfolders)
+ ", "
+ getResources().getQuantityString(R.plurals.count_files, countfiles, countfiles));
这是一个例外:
android.content.res.Resources$NotFoundException: Plural resource ID #0x7f050001 quantity=0 item=other
我必须维护多达 15 种不同的语言,因此我需要本地化文本和复数。
知道我的代码有什么问题吗?
提前谢谢了。