Android で複数リソースを利用しようとしましたが、うまくいきませんでした。
私の複数形のリソースファイルは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<plurals name="meters">
<item quantity="one">1 meter</item>
<item quantity="other">
<xliff:g id="count">%d</xliff:g>
meters
</item>
</plurals>
<plurals name="degrees">
<item quantity="one">1 degree</item>
<item quantity="other">
<xliff:g id="count">%d</xliff:g>
degrees
</item>
</plurals>
</resources>
...そして、リソースから数量文字列を抽出しようとするときに使用しているコードは次のとおりです。
Resources res = this.getResources();
tTemp.setText(res.getQuantityString(R.plurals.degrees, this.mObject.temp_c.intValue()));
...しかし、TextView のテキストは%d degrees
andのままです%d meters
。
誰が何が起こっているのか知っていますか?コードをデバッグしましたが、 res.getQuantityString(...) 呼び出しは、値が%d degrees
またはである文字列を返しています%d meters
。ただし、数量がたまたま 1 の場合は、1 degree
またはに正しく評価され1 meter
ます。
助けてくれてありがとう!
よろしく、セレスチャロブ。