Hardcoded string "下一步", should use @string resource警告 (转载)

转自:http://blog.csdn.net/iqv520/article/details/7579513

在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "下一步", should use @string resource

    <Button  
            android:id="@+id/button1"  
            android:layout_width="118dp"   
            android:layout_height="wrap_content"  
            android:text="下一步" />"  

虽然可以正常运行,但是这不是一个好习惯,应该在res/values/strings.xml中设置:

<?xml version="1.0" encoding="utf-8"?>  
<resources>  
    <string name="message">下一步</string>  
</resources> 

引用的时候使用

android:text="@string/message"

就行了。这样做可以做到一改全改,在支持多语言时也是很有用的。另外,颜色的设置也最好在color.xm中类似设置。

原文地址:https://www.cnblogs.com/lance-ehf/p/4272321.html