Jakob Harteg
Jakob Harteg

Reputation: 9747

What is this string doing?

I was looking at the widget sample in the google api demos, and i found this line in the strings.xml

<string name="appwidget_text_format"><xliff:g id="prefix">%1$s</xliff:g></string> 

and I don't understand what it's doing, I've never seen something like this, can someone please explain to me what's going on here.

I mean the whole, xliff:g and id, and especially the "%1$s". What's it doing?

Thanks very much

Upvotes: 0

Views: 99

Answers (3)

Bhanuka Withana
Bhanuka Withana

Reputation: 190

You better refer how to use Formatter to get more understanding on "%1$s" part.

Upvotes: 1

Ridcully
Ridcully

Reputation: 23655

xliff here is an additional namespace (should be specified in the xml header) and refers to the XML Localisation Interchange File Format.

The %1$s is a placeholder for a value you can later set in your Activity using the getString(int resId, Object... arg) method.

Upvotes: 3

aug
aug

Reputation: 11714

I believe it is a way to reference a string that is passed in as an argument. Take a look here in the Formatting strings where they give an example using it. Similarly you can do %2$d to reference a decimal.

Upvotes: 1

Related Questions