【问题标题】:XML document not well formedXML 文档格式不正确
【发布时间】:2013-09-25 02:50:15
【问题描述】:

我不确定为什么会收到“文档中根元素之后的标记必须格式正确”。我试图在 android 项目的 res/menu 下的 mainxml 中使用以下代码。请帮忙!!!

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_vertical|left"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cardHolderName" />

            <EditText
                android:id="@+id/cardHolderNameInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cardNumber" />

            <EditText
                android:id="@+id/cardNumberInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:paddingRight="40sp"
                android:text="@string/expirationDate" />

            <TextView
                style="@style/inputLabel"
                android:text="@string/expirationMonth" />

            <EditText
                android:id="@+id/expirationMonthInput"
                style="@style/textInput"
                android:layout_width="50sp"
                android:numeric="integer"
                android:singleLine="true" />

            <TextView
                style="@style/inputLabel"
                android:paddingLeft="10sp"
                android:text="@string/expirationYear" />

            <EditText
                android:id="@+id/expirationYearInput"
                style="@style/textInput"
                android:layout_width="50sp"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/cvv" />

            <EditText
                android:id="@+id/cvvInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <TextView
                style="@style/inputLabel"
                android:text="@string/amount" />

            <EditText
                android:id="@+id/amountInput"
                style="@style/textInput"
                android:layout_width="fill_parent"
                android:numeric="integer|decimal"
                android:singleLine="true" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/submitAction"
                style="@style/action"
                android:clickable="true"
                android:text="@string/submit" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>

任何帮助将不胜感激。谢谢。

【问题讨论】:

  • 这是你的 xml 中唯一的东西吗?发布 xml 文档的全部内容。还有文件在哪里,文件名是什么?
  • 对我来说看起来不错。你试过清理你的项目吗?或者复制文件的内容。删除文件并重新制作,然后将其粘贴回那里可能会解决问题。
  • 对不起,文件名为main.xml,在android项目的res/menu文件夹下。
  • 在我的回答中,这是一个布局文件而不是菜单

标签: android xml


【解决方案1】:

在 res/menu 下不能有布局文件。将main.xml文件移动到res/layout,应该没问题。

【讨论】:

    【解决方案2】:

    您很可能有未封闭的元素或未包含 android 命名空间。请发布整个 xml 文档以进行进一步说明。

    编辑: 您已将 xml 放在菜单下而不是布局下。

    【讨论】:

      猜你喜欢
      • 2011-02-20
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 2019-04-29
      • 2014-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多