-
Notifications
You must be signed in to change notification settings - Fork 0
Standardizing Strings
In the res > values folder, there's the strings.xml file which contains a list of Strings used by the Android application. This is the way Strings should be declared and utilized instead of hard-coding them into layout files, etc.
Inside the XML file, there exists a section for each Activity class and under each section are all the strings associated with that class. Here is a snippet to use as an example:
<!-- Strings for Login Activity -->
<string name="login_welcome_label">Welcome</string>
<string name="login_username">Username</string>
<string name="login_password">Password</string>
<string name="login_login_button">Login</string>
<string name="login_register_button">Register</string>
As you can see, these Strings all begin with the word "login" which is the class they are used in. The rest of the names are separated by underscores. There's a comment above this group of Strings to identify which Activity class they belong to as well.
To put it simply, organize the Strings your class will use together with the class' name as a prefix. Don't forget to stick a XML comment above the group of Strings to identify them.