[英]Why am I being asked to make my String in xml as @string reference?
android:text="Button"
doesn't work. android:text="Button"
不起作用。 I should make a special string for it in the values/strings.xml
and change the android:text="Button"
to android:text="@string/button"
for button having the value "Button"
. 我应该在
values/strings.xml
为其创建一个特殊的字符串,并将具有values/strings.xml
android:text="Button"
的android:text="Button"
更改为android:text="@string/button"
"Button"
。
What's the problem it used to work before? 它以前工作过的问题是什么?
Those are not error only warning, there is tool in every ide called lint which helps programmer to write code in standard format of that language. 这些不仅是错误警告,在每个想法中都有称为lint的工具,可以帮助程序员以该语言的标准格式编写代码。 In android standard practice is to use string.xml for storing all of your string value that is used in xml, so lint shows a warning that you should not directly set label hard-coded rather add them in string resource then set the resource id.
在android中,标准做法是使用string.xml来存储xml中使用的所有字符串值,因此lint显示警告,您不应直接设置硬编码标签,而应将其添加到字符串资源中,然后设置资源ID。
And there is some advantage of using string values like 并且使用诸如
etc 等等
You can find more information here -- 您可以在这里找到更多信息 -
hardcoded string "row three", should use @string resource 硬编码的字符串“第3行”,应使用@string资源
this answered my question, thank you, but if you have anything to add i'm glad to know it from you guys. 这回答了我的问题,谢谢,但是如果您有什么要补充的话,我很高兴收到你们的来信。 Best.
最好。
Alan 艾伦
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.