Android's strings.xml







It is located at res/values/strings.xml


A common place for strings constants. The purpose of this file is to move the string values out of the xml files. 






<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="hello">Hello World</string>
    <string name="app_name">My app name</string>
    <string name="Name">name</string>
    <string name="submit">submit</string>

</resources>









Example 1: manifest.xml



<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >



The @string/app_name is the application name which is coming from the strings.xml



Example 2: main.xml (layouts)


<TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Name" />

The @string/Name value at this TextView component is coming from the strings.xml




No comments:

Post a Comment