A string resource provides text strings for your application with optional text styling and formatting. There are three types of resources that can provide your application with strings:
All strings are capable of applying some styling markup and formatting arguments. For information about styling and formatting strings, see the section about Formatting and Styling.
String:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="string_name">text_string</string>
</resources>
- String
- XML resource that provides a single string.
- String Array
- XML resource that provides an array of strings.
- Quantity Strings (Plurals)
- XML resource that carries different strings for pluralization.
All strings are capable of applying some styling markup and formatting arguments. For information about styling and formatting strings, see the section about Formatting and Styling.
String:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="string_name">text_string</string>
</resources>
getting string like this on activity:
String mess = getResources().getString(R.string.string_name);
String Array:
<string-array name="tabs_names">
<item>My Tab 1</item>
<item>My Tab 2</item>
</string-array>
getting string array like this on activity:
String[] tab_names = getResources().getStringArray(R.array.tab_names);
Happy Coding!!