Here is the XML:
<string name="feature3_intro">You shot %1$d pounds of meat!</string>
Here is the java code:
int numPoundsMeat = 123;
String strMeatFormat = getResources().getString(R.string.feature3_intro);
String strMeatMsg = String.format(strMeatFormat, numPoundsMeat);
All that is appearing is: You shot %1$d pounds of meat!
help?
Thanks!
You don’t need to use the standard Java
String.format. Instead, your code should look like:That’s an overloaded version of Android’s
getStringmethod that takes a varargs list and does the formatting for you.