Android 什么';这个XML文件有什么问题?(不断崩溃aapt.exe)
我的应用程序和eclipse出现问题,所以我保存了代码,删除了eclipse,并重新下载和解压缩。在我将XML文件添加到res/menu后,我立即收到一条windows消息,说aapt.exe已停止工作;我以前一直收到这个消息。我以前研究过它,所以我知道如果XML文件编写不正确,aapt.exe将继续崩溃。唯一的问题是,我看不出这个文件有什么问题 createlgmenu.xml(用作按钮事件的弹出菜单): 到目前为止,我的activity_main.xml中只有一个按钮:Android 什么';这个XML文件有什么问题?(不断崩溃aapt.exe),android,xml,aapt,Android,Xml,Aapt,我的应用程序和eclipse出现问题,所以我保存了代码,删除了eclipse,并重新下载和解压缩。在我将XML文件添加到res/menu后,我立即收到一条windows消息,说aapt.exe已停止工作;我以前一直收到这个消息。我以前研究过它,所以我知道如果XML文件编写不正确,aapt.exe将继续崩溃。唯一的问题是,我看不出这个文件有什么问题 createlgmenu.xml(用作按钮事件的弹出菜单): 到目前为止,我的activity_main.xml中只有一个按钮: <Relati
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="@+id/CreateLG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="37dp"
android:layout_marginTop="21dp"
android:text="+"
android:textSize="40sp" />
</RelativeLayout>
如果您想查看my menu.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
我想我已经找到了解决办法 我自己复制了xml并更改了项目。所以我删除了它,并通过Eclipse创建了它(右键单击res/menu文件夹>新建>其他>Android XML文件>菜单)。我似乎不再收到appt.exe错误。然后,我使用Eclipse添加了这些项,而不是自己编写或复制它们 这两个文件的唯一区别在于,旧文件以以下内容结束每个项目:
\>
Eclipse创建的一个在项目声明的末尾使用:
></item>
>
至于Eclipse无法识别我的xml文件,AdamM也帮助我找到了该问题的解决方案:
1) 我删除了R导入
2) 注释掉了在识别xml文件时给我带来错误的行
3) 重新启动Eclipse&builded All如果您使用的是支持库和库项目,那么对于较旧的平台版本,您需要为“showAsAction”标记提供一个自定义名称空间 因此,改变这一点:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
为此:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
custom:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
请注意,“自定义”可以是您想要的任何内容。您是否将android:id=“@id/Create_List”更改为android:id=“@+id/Create_List”,我看到您的menu.xml是正确的,请尝试清理您的项目。不,它总是显示@+id。此外,当我的res/menu中有createlg_menu.xml时,我似乎无法清理我的项目,因为aapt.exe不再清理项目,而是再次停止工作。如果删除createlg_menu.xml,则项目会自行清理。我还应该说,我的MainActivity.java从未检测到createlg_菜单(最初称为createlgmenu),它认为它不存在。它也没有说其他东西存在,比如CreateLG,我唯一的按钮的按钮id(它过去很好…)。
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
custom:showAsAction="never"
android:title="@string/action_settings"/>
</menu>