Android XML 文档结构必须在同一实体内开始和结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23154504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 06:50:42  来源:igfitidea点击:

XML document structure must start and end within the same entity

androidxml

提问by Kingsley

I'm quite a newbie for the eclipse, and I'm just started to write some code(actually it's just copy and paste from the website) can anyone help me about this??? *the error is appear on the last line

我是日食的新手,我刚刚开始编写一些代码(实际上只是从网站复制和粘贴)有人可以帮助我吗???*错误出现在最后一行

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >

    </ToggleButton>

回答by sergio91pt

You need to close the LinearLayout tag.

您需要关闭 LinearLayout 标记。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >

    </ToggleButton>
</LinearLayout>

回答by Amardeepvijay

use this code :

使用此代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <ToggleButton
        android:id="@+id/toggleButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >

    </ToggleButton>
</LinearLayout>

回答by Blangero

XML document structure must start and end within the same entity, as you can see, there's a < ToggleButton .... > and a < /ToggleButton > which make a pair, but < LinearLayout .... > still needs something to make a pair.

XML 文档结构必须在同一个实体中开始和结束,如您所见,有一个 < ToggleButton .... > 和一个 </ToggleButton > 成对,但是 < LinearLayout .... > 仍然需要一些东西来制作一双。

I think it's better for you to have a better understanding of XML, it's quite easy and useful.here's a good tutorial:

我觉得你对XML有更好的理解会更好,它非常简单有用。这里有一个很好的教程:

https://developer.mozilla.org/en/docs/XML_Introduction

https://developer.mozilla.org/en/docs/XML_Introduction