I got an odd problem. The getQuantityString()
method working on android studio simulator, but not working on the real device.
This is my code in strings.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals name="subtitle_plural">
<item quantity="one">%1$s crime</item>
<item quantity="other">%1$s crimes</item>
</plurals>
</resources>
code in my Fragment:
CrimeLab crimeLab = CrimeLab.get(getActivity());
int crimeSize = crimeLab.getCrimes().size();
String subTitle = getResources()
.getQuantityString(R.plurals.subtitle_plural, crimeSize, crimeSize);
When I run the project on the simulator, it works. but if run it on real device, subTitle
will always be ** crimes
even if crimeSize
equals 1
.
How did this happen?