加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Error parsing XML: junk after document element

发布时间:2020-12-16 00:40:17 所属栏目:百科 来源:网络整理
导读:今天开始接触android的Java编程,出现问题了。 我的代码是这样的: 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

今天开始接触android的Java编程,出现问题了。

我的代码是这样的:

<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"
tools:context=".MainActivity" >

</LinearLayout>

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

应该把</LinearLayout>放在最后一行。

原因:

这里Android123提示大家一般合法的XML文件只有一个主根节点,比如

<android123>
<item1/>
<item2/>
<item3/>
</android123>

如果出现了Error parsing XML: junk after document element这样的错误,你的想法可能只要主根有多个节点,比如说

<android123> <item1/> </android123> <android123> <item2/> <item3/> </android123>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读