2012-07-31 19 views
5

我正在從「hello to android」這本書中練習「sudoku」。 我看到有些人和我有同樣的問題,但我無法解決它。 我已經刪除了三次這個項目,並從頭開始重新創建,但我仍然在下面收到相同的錯誤消息,即使我正在從本書複製/粘貼。錯誤:找不到與給定名稱相匹配的資源(在'title'處,值爲'@ string/menu_settings')

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> 

謝謝您的幫助!

+0

我認爲問題是在xml activity_main不是你發佈的,它似乎是尋找一個名爲hello_world和menu_settings的字符串,它不存在。 – MikeIsrael 2012-07-31 14:02:29

+2

您粘貼了錯誤的xml。檢查你的錯誤輸出。 – 2012-07-31 14:02:32

+0

告訴我們activity_main.xml ....或者乾脆將它添加到string.xml中 hi那就是它。 – Shark 2012-07-31 14:02:58

回答

3

如果您使用Elcipse插件創建了Android應用程序,在res文件夾中您有一個菜單文件夾,並且在該文件夾內還有另一個activity_mail.xml

刪除文件或評論其內容,因爲您不會使用sudoku app的菜單。

這應該解決它。

2

要麼添加

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

您string.xml

或找到您activity_main.xml中稱爲 '標題' 的觀點,並刪除了android:文本= 「@字符串/程序hello_world」 財產它。

0

res>menu中刪除文件activity_main.xml,因爲res>menures>layout中有兩個同名的文件。

相關問題