strings.xml和@string的用法

1、layout的代码:

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FF0000"
android:textSize="70px"
android:text=" @string/hello" />

2、strings.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">FirstProject</string>
<string name="hello">Hello world!</string>
<string name="action_settings">Settings</string>
</resources>

解释:@string/hello指的是在strings.xml文件中定义的hello字符串,即hello字符串中存有“Hello world!”,并在界面中输出。这种用法在将引用程序本地化为另一种语言时用到。

3、stings.xml

用来存储应用程序中所有 字符串常量。这使得您可以很容易地通过替换这些字符串并重新编译应用程序来本地化您的应用程序

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念