0

这是我的 about.xml 文件,它是布局文件

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_text"
android:id="@+id/abouttextview"></TextView>
</ScrollView>

这是 strings.xml 文件,其中包含单击 about 按钮时要显示的内容

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, Hangman!</string>
    <string name="app_name">Android Hangman</string>
    <string name="about_text">Hangman is the classic game that has
    players
    trying to guess their opponent's mystery word first--and
    before
    getting hanged. For every wrong letter chosen, a bit more
    of the hangman is exposed.</string>
    <string name="about_title">About Android Hangman</string>
 </resources>

我在 about.xml 的 android:text=@strings/about_Text 行收到错误,找不到与给定名称匹配的资源

4

3 回答 3

1

您需要将\符号放在特殊字符之前strings.xml

对手的

      ^^

字符串.xml

<string name="about_text">Hangman is the classic game that has
    players
    trying to guess their opponent\'s mystery word first--and
    before
    getting hanged. For every wrong letter chosen, a bit more
    of the hangman is exposed.</string>

关于.xml

<ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/abouttextview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/about_text" >
        </TextView>
    </ScrollView>

它在我的情况下工作。

于 2013-04-27T06:56:36.030 回答
0

我看到的唯一问题是字符串资源中单词的撇号\前缺失。'opponent's

将其更改为:

<string name="about_text">Hangman is the classic game that has
players
trying to guess their opponent\'s mystery word first--and
before
getting hanged. For every wrong letter chosen, a bit more
of the hangman is exposed.</string>
于 2013-04-27T06:57:30.367 回答
0

1)保存你所有的工作

2)选择项目并右键单击,然后刷新

3)选择项目>清理

它应该工作

注意:在任何特殊字符(非字母数字字符)之前放置“/”

于 2013-04-27T06:58:03.713 回答