Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java “硬编码钉扎”;“x”;,应该使用@string资源_Java_Android_Xml_Eclipse - Fatal编程技术网

Java “硬编码钉扎”;“x”;,应该使用@string资源

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

我在布局文件夹中的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_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中声明它们。事实上,这篇文章应该是一篇评论。没有答案。