Assuming you want to pass a string value as a parameter to another_string
, then your string will not be well formatted to receive this argument, and if you try to use it, your result will be {$some_string} trolololo
.
If you need to format strings using String.format (String, Object ...) , you can do this by putting your format arguments in a String resource.
<resources> <string name="some_string">string1</string> <string name="another_string">%1$s trolololo</string> </resources>
Now you can format the string with arguments from your application as follows:
String arg = "It works!"; String testString = String.format(getResources().getString(R.string.another_string), arg); Log.i("ARG", "another_string = " + testString);
So the output line will be another_string = It works! trolololo
another_string = It works! trolololo
.
Take a look at the official Android developers documentation here .
source share