eclipse 错误:找不到与给定名称匹配的资源(在 'title' 处,值为 '@string/menu_settings')

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11741849/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:42:48  来源:igfitidea点击:

Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings')

javaandroideclipsestring

提问by user1805

I'm doing the exercise "sudoku" from the book "hello to android". I saw some people have the same issue as me but I'm unable to solve it. I have deleted three times this project and re-create from the beginning but I keep getting the same error message on below, even if I'm doing a copy/paste from the book.

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

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').

There is the code inside the book for the Sudokuv1/res/layout/main1.xml:

书中有以下代码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>    

There is the code for Sudokuv1/res/values/strings.xml:

有以下代码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>

Thank you for your help!

感谢您的帮助!

采纳答案by Felipe

If you created the android app with the Elcipse plugin, in the resfolder you have a menu folder and inside that folder there is another activity_mail.xml.

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

Erase the file or comment its content since you wont be using the menu for the sudoku app.

擦除文件或评论其内容,因为您不会使用sudoku app.

That should fix it.

那应该解决它。

回答by Shark

either add

要么添加

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

to your string.xml

到你的 string.xml

or find the view called 'title' in your activity_main.xml and erase the android:text="@string/hello_world" property from it.

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

回答by Suresh

Delete the file activity_main.xmlfrom res>menubecause there are two files with the same name in res>menuand res>layout.

删除文件activity_main.xmlres>menu因为有两个文件同名res>menures>layout