Apr 28, 2017

Androi strings.xml

<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="good_example">This is a \"good string\".</string>
<string name="bad_example">This is a "bad string".</string>
    <!-- Quotes are stripped; displays as: This is a bad string. -->
<string name="bad_example_2">'This is another "bad string".'</string>
    <!-- Causes a compile error -->

<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
Resources res = getResources();
String text = res.getString(R.string.welcome_messages, username, mailCount);

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="welcome">Welcome to <b>Android</b>!</string>
</resources>

No comments:

Post a Comment