Android:Resource:String
lastmod 2014-06-12created 2014-01-155 edits
Android: Multiple substitutions specified in non-positional format
- Android: Multiple substitutions specified in non-positional format
- Multiple substitutions specified in non-positional format error
When working with Android ADT 2.3, you may sometimes get the Multiple substitutions specified in non-positional format error.
The error occurs when you put in multiple substitutable items like this, and the fix is
This form is used for cases where the order changes in a particular Locale.
Here, 1$ and 2$ are the Argument order.
If you want to disable format checking, add the formatted="false" attribute as shown below.
Plurals
To handle singular and plural strings, use Plurals.
Example
The XML example is as follows.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<plurals name="numberOfSongsAvailable">
<item quantity="one">One song found.</item>
<item quantity="other">%d songs found.</item>
</plurals>
</resources>
The Java code is as follows.
int count = getNumberOfsongsAvailable();
Resources res = getResources();
String songsFound = res.getQuantityString(R.plurals.numberOfSongsAvailable, count, count);
Pages that link here