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.
  1. 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).
  2. 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.

  3. Figure 7. The dialog to add a new string
    Click Add Key  to create a new string as the "hint text" for the text box.
    1. Enter "edit_message" for the key name.
    2. Enter "Enter a message" for the value.
    3. Click OK.
  4. 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:
  1. 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.
  2. 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.
  3. Still viewing the text box properties, also delete the value for the text property (currently set to "Name").
  4. Now click the button in the layout, locate the text property, click Pick a Resource, and then select button_send.

Comments

Popular posts from this blog

Make the text box size flexible

Add Text box & Button