所以今天我开始在这个视频之后构建我的第一个Android应用程序:http://www.youtube.com/watch?v=U5Qi0lb_3nE
在做了大约一半的视频后,我收到了一个错误“根元素后面的文档中的标记必须格式正确”
我无法看到问题,所以这里是我的代码:
<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。
感谢您的帮助!
答案 0 :(得分:4)
您在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">