【问题标题】:Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings')错误:未找到与给定名称匹配的资源(在“标题”处,值为“@string/menu_settings”)
【发布时间】:2012-07-31 13:58:41
【问题描述】:

我正在做“hello to android”一书中的“数独”练习。 我看到有人和我有同样的问题,但我无法解决。 我已经删除了三遍这个项目并从头开始重新创建,但即使我正在从书中复制/粘贴,我仍然在下面收到相同的错误消息。

W/ResourceType( 8592): Bad XML block: header size 29806 or total size 538970658 is larger than data size 0
    C:\java\Sudoku\res\layout\activity_main.xml:6: error: Error: No resource found that matches the given name (at 'text' with value '@string/hello_world').
C:\java\Sudoku\res\menu\activity_main.xml:2: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').

书里面有Sudokuv1/res/layout/main1.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/main_title" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/continue_label" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/new_game_label" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/about_label" />
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/exit_label" />
</LinearLayout>    

Sudokuv1/res/values/strings.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Sudoku</string>
<string name="main_title">Android Sudoku</string>
<string name="continue_label">Continue</string>
<string name="new_game_label">New Game</string>
<string name="about_label">About</string>
<string name="exit_label">Exit</string>
</resources>

感谢您的帮助!

【问题讨论】:

  • 我认为问题出在 xml activity_main 而不是您发布的那个,它似乎正在寻找一个名为 hello_world 和 menu_settings 的字符串,但它们不存在。
  • 您粘贴了错误的 xml。检查您的错误输出。
  • 向我们展示 activity_main.xml .... 或者简单地将其添加到 string.xml hi 就是这样。

标签: java android eclipse string


【解决方案1】:

如果您使用 Elcipse 插件创建了 android 应用程序,则在 res 文件夹中您有一个菜单文件夹,并且在该文件夹中还有另一个 activity_mail.xml

删除文件或评论其内容,因为您不会使用sudoku app 的菜单。

这应该可以解决它。

【讨论】:

    【解决方案2】:

    要么添加

    <string name="hello_world">hi</string>
    

    到你的 string.xml

    或在您的 activity_main.xml 中找到名为“title”的视图并从中删除 android:text="@string/hello_world" 属性。

    【讨论】:

      【解决方案3】:

      res&gt;menu 中删除文件activity_main.xml,因为res&gt;menures&gt;layout 中有两个同名文件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-09-28
        • 1970-01-01
        • 1970-01-01
        • 2015-03-17
        • 2016-09-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多