Hardcoded string "Button", should use @string resource

来源:互联网 发布:淘宝客服售后面试问题 编辑:程序博客网 时间:2024/06/05 16:00

遇到这个错误是在写xml文件中一个button上的字的时候,书上就是这样写的

android:text="Button"


我就这样写了,可是就是出现了标题的警告。找了一些解决方法。不怎么好--是添加一个xml文件。

仔细分析出错信息就是它是在提醒怎么做的。找到这样简单有效的方法:

android:text="@string/Button" 

就不再有警告了。



但是在我直接上用边的方法的时候,偶尔也会出现这种问题:

error: Error: No resource found that matches the given name (at 'text' with value '@string/Button1').

这个是java文件中写的有错误。

button1 = (Button)this.findViewById(R.id.button1);

里边的button1写成了button




原创粉丝点击