2013-10-12 38 views
1

所以今天我開始建立以下這個視頻我的第一個Android應用:http://www.youtube.com/watch?v=U5Qi0lb_3nEEclipse的錯誤「的文件標記也必須是合式

做有關視頻的後半段我得到了一個錯誤「下面的根元素的文檔中的標記也必須是形成」

我看不到的問題,所以這裏是我的代碼有:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" 
tools:ignore="MergeRootFrame" /> 

<TextView android:id="@+id/text" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:text="Hello!" /> 

<TextView android:id="@+id/text" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="This is my first android application!" /> 

<Button android:id="@+id/button" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text ="And this is a Clickable button!!!" /> 
</FrameLayout> 

現貨在視頻中我被困在約9分鐘。

對不起,我從來沒有用過Stockover。

感謝您的幫助!

回答

3

您在XML文檔中有多個根元素,並且只能有一個。您需要將最終/>更改爲>第一個元素(FrameLayout裏):

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" 
tools:ignore="MergeRootFrame"> 
+0

嗯,是啊,修復了,但只要我固定的,3個錯誤彈出... 2錯誤在兩個「TextView」行中,最後一行在「Button」行。錯誤是「錯誤:錯誤:找不到匹配給定名稱的資源(在」文本「中,值爲」@ string/Hello!「&另一個在 – user2872834

+0

對不起,哈哈,每次我按回車,它都會發布。 – user2872834

+0

你需要進入strings.xml文件(res> values> strings.xml)並添加這些值,例如' Hello!',或者你可以通過刪除' @ string /'那一行的一部分 – ashatte

相關問題