2014-02-20 215 views
7

我已經更新了我的機器人工作室,現在我在我main.xml中的一個問題,它會顯示以下錯誤: element LinearLayout must be declared元素的LinearLayout必須聲明

這是我的代碼:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:gravity="center_vertical|center_horizontal" 
    > 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/monBouton" 
     android:text="Cliquez ici !" 
     > 
    </Button> 
</LinearLayout> 

這是錯誤消息: 錯誤:執行任務':app:compileDebugJava'失敗。

Compilation failed; see the compiler error output for details.

錯誤:無法找到符號變量action_settings

我該如何解決呢?

+0

包括完整的錯誤信息。 – pyus13

+0

包含完整的錯誤信息,謝謝 – abdoBim

+0

我有同樣的錯誤,原因是因爲我把xml文件放在'drawable /'裏面而不是'layout /'目錄。 –

回答

3

確保您已經菜單裏面的XML文件

res/menu/yourmenufile.xml 

定義action_settings這樣的:

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context="com.example.app" > 

    <item android:id="@+id/action_settings" 
     android:title="@string/action_settings" 
     android:orderInCategory="100" 
     app:showAsAction="never" /> 
</menu> 
+0

謝謝,呃解決方案:) – abdoBim

4

有同樣的錯誤。問題是,我的菜單文件夾中有我的dialogfragment佈局,而不是佈局文件夾

相關問題