0

我不确定为什么会收到“根元素之后的文档中的标记必须格式正确”。我试图在 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>

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

4

2 回答 2

4

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

于 2013-09-25T02:59:25.993 回答
1

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

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

于 2013-09-25T02:51:49.207 回答