13

Why is this working?

<string name="quantity_geoFormat">"%s"</string>

And this not?

<string name="quantity_geoFormat">"%s %s"</string>

For the second I am getting this error: Multiple substitutions specified in non-positional format;

1 Answer 1

40

You need to use the positional substitution format, which looks like this: %1$s.

Thus your second string resource should look like this:

<string name="quantity_geoFormat">"%1$s %2$s"</string>
Sign up to request clarification or add additional context in comments.

2 Comments

For the new guy out there...to grab it in code. geoFormat = String.format(getString(R.string.quantity_geoFormat), string1, string2);
Also don't copy the quotes if you don't want them in your output String.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.