Hardcoded string XXX, should use @string resource警告
问题:直接编辑edit text输入文字会报警告警告代码:
<Button
android:id="@+id/clock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginLeft="16dp"
android:layout_marginTop="58dp"
android:text="点击我" />
解决办法:
1. 在res/values/strings.xml中设置
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="click">点击我</string>
</resources>
2. 引用时使用
android:text="@string/click"
查看完整版本: Hardcoded string XXX, should use @string resource警告
Tags: