Monday, 29 July 2013

Styling and formatting in xml android file like quotes

Most information about styling and formating text can be found in android doc page:
Formatting and Styling

Escaping apostrophes and quotes
<string name="good_example">"This'll work"</string>
<string name="good_example_2">This\'ll also work</string>
<string name="bad_example">This doesn't work</string>
<string name="bad_example_2">XML encodings don&apos;t work</string>

Formatting strings

In code:

String string = String.format(getString(R.string.welcome_messages), "Mike", 2);

In resources:
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>