Change the UI strings
Change the UI strings
Click Show Design in the toolbar to preview the UI. Notice that the text input is pre-filled with "Name" and the button is labeled "Button." So now you'll change these strings.
- Open the Project window and then select res > values > strings.xml.This is a string resources file where you should specify all your UI strings. Doing so allows you to manage all UI strings in a single location, which makes it easier to find, update, and localize (compared to hard-coding strings in your layout or app code).
- Click Open editor at the top of the editor window. This opens the Translations Editor, which provides a simple interface for adding and editing your default strings, and helps keep all your translated strings organized.
- Enter "edit_message" for the key name.
- Enter "Enter a message" for the value.
- Click OK.
- Add another key named "button_send" with a value of "Send."
Now you can set these strings for each view. So return to the layout file by clickingactivity_main.xml in the tab bar, and add the strings as follows:
- Click the text box in the layout and, if the Properties window isn't already visible on the right, click Properties on the right sidebar.
- Locate the hint property and then click Pick a Resource to the right of the text box. In the dialog that appears, double-click on edit_message from the list.
- Still viewing the text box properties, also delete the value for the text property (currently set to "Name").
- Now click the button in the layout, locate the text property, click Pick a Resource, and then select button_send.
Comments
Post a Comment