2013-05-19 36 views
-1

嗨,我有我的活動的錯誤,我不知道爲什麼 錯誤行顯示6「的LinearLayout」必須遵循的任一屬性規範「>」或「/>」中的Android

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:gravity="center" 
android:orientation="vertical" 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="24dp" 
    android:text="@string/question_text" 
    /> 
<LinearLayout 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:gravity="center" 
android:orientation="horizontal" 
    <Button 
     android:id="@+id/true_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/true_button" 
     /> 
    <Button 
     android:id="@+id/false_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/false_button" 
     /> 

    </LinearLayout> 

</LinearLayout> 

這裏是我的strings.xml

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

<string name="app_name">GeoQuiz</string> 
<string name="question_text">Constantinople is the largest city in turkey</string> 
<string name="true_button">True</string> 
<string name="false_button">False</string> 
<string name="action_settings">Settings</string> 
</resources>' 

,這裏是我的其他自動生成的XML文件

<menu xmlns:android="http://schemas.android.com/apk/res/android" > 

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

</menu> 

該FI le在第5行顯示一個錯誤,它表示錯誤:錯誤:找不到與給定名稱匹配的資源(位於'title',值爲'@ string/action_settings')。

那麼如何才能解決這個感謝

回答

1

請看這個答案:https://stackoverflow.com/a/16631008/1306419。嘗試從那裏提取有用的信息。

嘗試類似:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical"> 
... 
... 
</LinearLayout> 

注意:當我開始<LinearLayout標籤,我在它的末端使用>。 希望它有幫助。

1

你沒有用閉上你的線性佈局標籤>。所以它找不到第一個標籤的結尾。

+0

哦,我忘了貼我的代碼,我已經把佈局標籤在年底的最後一部分,它仍然給了我這個錯誤 –

+0

如果粘貼整個佈局文件可能會有所幫助。 –

0

我不認爲你有我的第一個答案。正好試試這個:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:padding="24dp" 
     android:text="@string/question_text" 
     /> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center" 
     android:orientation="horizontal" > 
     <Button 
      android:id="@+id/true_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/true_button" 
     /> 
     <Button 
      android:id="@+id/false_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/false_button" 
     /> 
    </LinearLayout> 
</LinearLayout> 
相關問題