strings.xml和@string的用法
发布时间:2020-12-16 09:39:29 所属栏目:百科 来源:网络整理
导读: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="u
1、layout的代码: <TextViewandroid: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"?> 解释:@string/hello指的是在strings.xml文件中定义的hello字符串,即hello字符串中存有“Hello world!”,并在界面中输出。这种用法在将引用程序本地化为另一种语言时用到。 3、stings.xml 用来存储应用程序中所有 字符串常量。这使得您可以很容易地通过替换这些字符串并重新编译应用程序来本地化您的应用程序 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |