我正在尝试在Eclipse中创建一个Android项目。在菜单目录中,我试图替换现有的main.xml的内容。但
<menu xmlns:android="http://schemas.android.com/apk/res/android"></menu>
不管我删除多少次,它始终显示为main.xml的最底行。到底是怎么回事?我需要关闭Eclipse中的某种设置类型吗?
并在Eclipse的行旁显示一条错误消息:
“文档中根元素之后的标记必须格式正确。”
我想用以下内容替换main.xml:
<?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" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtSpace" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtFirstNumber" />
<EditText
android:inputType="numberDecimal"
android:id="@+id/EditText01"
android:layout_width="fill_parent"
android:layout_height="wrap_content" > </EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtSpace" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txtSecondNumber" />
<Button
android:text="Multiply"
android:id="@+id/Button01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"> </Button>
</LinearLayout>
最佳答案
我也有这个问题。
在以下位置检查Eclipse设置:
窗口->首选项-> Java->编辑器->保存操作|在保存时执行选定的操作