Whats up Geeks,
In the last tutorial we have learned Adding a Text Field.
In this tutorial we are going to learn Adding a String Resources.
So the question comes what is the use of String Resources addition?
And the answer is :
When we need to add text in the user interface, we should always specify each string as a resource.
Now the question arise what this String resources do?
And the answers is:
String resources allow to manage all UI text in a single location, which makes it easier to find and update text. Externalizing the strings also allows you to localize your app to different languages by providing alternative definitions for each string resource.
Where does these String resides?
By default, your Android project includes a string resource file at
Add a new string named
While you’re in this file, also add a "Send" string for the button you’ll soon add, called
For example:
The result for
That's all for today. See ya tomorrow with some new learnings.
In the last tutorial we have learned Adding a Text Field.
In this tutorial we are going to learn Adding a String Resources.
So the question comes what is the use of String Resources addition?
And the answer is :
When we need to add text in the user interface, we should always specify each string as a resource.
Now the question arise what this String resources do?
And the answers is:
String resources allow to manage all UI text in a single location, which makes it easier to find and update text. Externalizing the strings also allows you to localize your app to different languages by providing alternative definitions for each string resource.
Where does these String resides?
By default, your Android project includes a string resource file at
res/values/strings.xml
.Add a new string named
"edit_message"
and set the value to "Enter a message." (You can delete
the "hello_geeks" string.)While you’re in this file, also add a "Send" string for the button you’ll soon add, called
"button_send"
.For example:
The result for
strings.xml
looks like this:<?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Hello Geeks</string> <string name="edit_message">Enter a message</string> <string name="button_send">Send</string> <string name="action_settings">Settings</string> <string name="title_activity_main">MainActivity</string> </resources>
That's all for today. See ya tomorrow with some new learnings.
No comments:
Post a Comment