Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/188.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 代码没问题,但我得到了一个错误——XML文档结构必须在同一个实体中开始和结束_Android_Xml - Fatal编程技术网

Android 代码没问题,但我得到了一个错误——XML文档结构必须在同一个实体中开始和结束

Android 代码没问题,但我得到了一个错误——XML文档结构必须在同一个实体中开始和结束,android,xml,Android,Xml,我将迈出android编程和XML的第一步。我用的是《大书呆子牧场指南》。在Eclipse中,我使用了书中给出的XML,我得到了一个错误:XML文档结构必须在同一个实体中开始和结束 我该如何解决这个问题 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match

我将迈出android编程和XML的第一步。我用的是《大书呆子牧场指南》。在Eclipse中,我使用了书中给出的XML,我得到了一个错误:XML文档结构必须在同一个实体中开始和结束

我该如何解决这个问题

<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:orientation="horizontal" >    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/true_button" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/false_button" />
    </LinearLayout>    
</LinearLayout>

问题已解决。我删除了代码并保存了xml文件。之后,我用上面的代码替换了它并保存了它。错误消失了。它可能是启用“自动构建项目”时的遗留问题


奇怪。

你从哪里得到这个错误的?我把它放在Eclipse中,没有得到那个错误。@hichris123-谢谢。这可能是eclipse的一些问题。我回答了我自己的问题。