2013-07-15 26 views
1

這是我的第一個Android項目,我不能調試此次培訓程序Building a Simple User Interface錯誤在我的Android項目中的XML文件

當我調試它的運行我看到這一點:

錯誤的XML文件:中止構建。

(Android設備:提示= 「@字符串/ edit_message」/>)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" 

<EditText android:id="@+id/edit_message" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:hint="@string/edit_message" /> 
<Button 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="@string/button_send" 

</LinearLayout> 
+0

你創建一個裏面的strings.xml名edit_message串關閉第一「的LinearLayout」? – Blackbelt

+2

你在按鈕結尾還缺少'/>'。你還應該在strings.xml中定義一個名爲'edit_message'的字符串 – Raghunandan

+0

你可以在這個頁面找到完整的佈局:http://developer.android.com/training/basics/firstapp/building-ui.html。 – Brtle

回答

2

您沒有及時關閉<LinearLayout><Button>標籤。即使StackOverflow語法highligting暗示這一點。試試這個:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="horizontal" > 

<EditText android:id="@+id/edit_message" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:hint="@string/edit_message" /> 

<Button 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:text="@string/button_send" /> 

</LinearLayout> 
0

你有一個名爲「edit_message」的字符串。

如果是,爲什麼在你的代碼,你不同意這個「>」

相關問題