Usually, it is a practice for Android application to store the string values for user interface reference in the XML file due to the nature of mobile apps, which is distributed internationally. So it is best to provide multiple language options. However, this practice is optional, and you may use direct string assigning if you wish to do so.
The string resource file is in an XML form and available through the project tree in res/values/strings.xml
. These string resources can also be used to store color information, integer arrays to name some.
Now, add a new string value by clicking on the Add button, provide the variable name in the Name box and the Value of the string. Press Ctrl + S to save the changes. For example, in the following screenshot, a new string variable is created as hello_u
and the value is Hello,:
Add two more string values based on the table that follows. These strings will be used as the widgets' caption:
String variable |
Value... |
---|