2015年10月18日 星期日

String Resource

In android, the string can as a Resource, define in the xml.
1.define the String, in strings.xml

<resources>
    <string name="app_name">L013String</string>
    <string name="word">Word</string>
</resources>


2.Use in other XML,e.g.,activity_main.xml


<TextView android:text="@string/word" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />


3. Use in the program java code.





 String w=getResources().getString(R.string.word);