Java “硬编码钉扎”;“x”;,应该使用@string资源
我在布局文件夹中的xml文件中遇到此错误。我将其更改为android:text=“@string/x”,但随后在按钮上显示: 这是我的主菜单.xml:Java “硬编码钉扎”;“x”;,应该使用@string资源,java,android,xml,eclipse,Java,Android,Xml,Eclipse,我在布局文件夹中的xml文件中遇到此错误。我将其更改为android:text=“@string/x”,但随后在按钮上显示: 这是我的主菜单.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="150dp" android:layout_height="match_parent" android:layout_margi
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="150dp"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
android:orientation="vertical" >
<TextView
android:id="@+id/menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Menu" //warning here
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/one_player"
android:layout_width="115dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="1player" />//warning here
<Button
android:id="@+id/two_player"
android:layout_width="115dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="2players" />//warning here
<Button
android:id="@+id/exit_game"
android:layout_width="wrap_content"
android:layout_marginTop="20dp"
android:layout_height="115dp"
android:text="exitgame" />//warning here
</LinearLayout>
//警告这里
//警告这里
//警告这里
看起来您忘记实际声明字符串中的变量。xml
看起来您忘记实际声明字符串中的变量。xml
看起来您忘记实际声明字符串中的变量。xml
看起来您忘记实际声明strings.xml中的变量
您需要在res->values->string.xml下定义字符串
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="player_1"
1player</string>
</resources>
您需要在res->values->string.xml下定义字符串
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="player_1"
1player</string>
</resources>
您需要在res->values->string.xml下定义字符串
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="player_1"
1player</string>
</resources>
您需要在res->values->string.xml下定义字符串
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="player_1"
1player</string>
</resources>
我确实忘了在strings.xml中声明它们。事实上,这篇文章应该是一篇评论。不是答案。我确实忘了在strings.xml中声明它们。事实上,这篇文章应该是一篇评论。不是答案。我确实忘了在strings.xml中声明它们。事实上,这篇文章应该是一篇评论。不是答案。我确实忘了在strings.xml中声明它们。事实上,这篇文章应该是一篇评论。没有答案。