When I first saw %1$s and %2$d in the accepted answer, it made no sense. Here is a little more explanation.
String format replacement markers in xml are in the form of
%[parameter index]$[format type]
parameter index: If you had three parts of the string that you wanted to replace, then they would be called %1, %2, and %3. The order you place them in the resource string doesn’t matter, only the order that you supply the parameters in String.format.
format type: There are a lot of ways that you can format things (see the documentation). Here are some common ones:
$d decimal integer
$f floating point number
Use %% to get the actual % character.
For more details read the following helpful tutorial.
Android SDK Quick Tip: Formatting Resource Strings
Create the following formatted string where the gray parts can be replaced programmatically.
12 is an int and Hello is a String.
int myInt = 12;
String myString = “Hello”;
String myFormattedString = String.format(getString(R.string.my_xml_resource_string), myInt, myString);
%1$d is an int and %2$s is a String.