Hardcoded string Button should use string resource

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

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

android:text="Button"


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

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

android:text="@string/Button" 

就不再有警告了。

扫描二维码关注公众号,回复: 4084751 查看本文章



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

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




           

给我老师的人工智能教程打call!http://blog.csdn.net/jiangjunshow

这里写图片描述

猜你喜欢

转载自blog.csdn.net/hfyutdg/article/details/84065479
今日推荐