Error parsing XML: junk after document element

今天開始接觸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>


發佈了27 篇原創文章 · 獲贊 16 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章