Android应用程序,必须在良好的根元素下列文件中的标记应用程序、下列、标记、元素

2023-09-07 09:06:36 作者:草莓雨

我已经开始从下面的链接模块6.1项目工作的一些Android的教程演示的 http://www.vogella.de/articles/Android/article.html

I had started to work on some android tutorial demo's from below link module 6.1 Project http://www.vogella.de/articles/Android/article.html

我收到以下错误通知在日食用于以下menu.xml文件菜单标签:

Am getting following error notification in eclipse for the menu tag in below menu.xml:

The markup in the document following the root element must be well-formed.

menu.xml文件(路径:/ RES /菜单)

menu.xml (path: /res/menu)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button android:id="@+id/Button01" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Show Preferences"></Button>
    <Button android:id="@+id/Button02" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="Change Preferences"></Button>
</LinearLayout>
   <menu xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:title="Prefernces" android:id="@+id/Prefernces"></item>
</menu>

在控制台我收到以下错误:

In console am getting following error:

[2011-08-17 14:47:00 - Preferences] D:\AndroidWorkSpace\Preferences\res\menu\menu.xml:10: error: Error parsing XML: junk after document element
[2011-08-17 14:47:02 - Preferences] W/ResourceType( 3524): Bad XML block: no root element node found
[2011-08-17 14:47:02 - Preferences] D:\AndroidWorkSpace\Preferences\res\menu\menu.xml:10: error: Error parsing XML: junk after document element

我失去了一些东西。

am i missing some thing.

推荐答案

在哪里,最后菜单标签从何而来? 您应该只有一个根(即第一级)的标签,这将是的LinearLayout 在这里。

Where do the last menu tag come from? You should only have one root (ie 1st level) tag, which would be LinearLayout here.