Java 错误:处理指令目标匹配“;[xX][mM][lL]";不允许
我正在使用eclipse编写一个android应用程序,我停了下来。我试着用Java 错误:处理指令目标匹配“;[xX][mM][lL]";不允许,java,android,xml,eclipse,Java,Android,Xml,Eclipse,我正在使用eclipse编写一个android应用程序,我停了下来。我试着用 <?xml version="1.0" encoding="utf-8"?> 但我一直收到错误信息 “与“[xX][mM][lL]”匹配的处理指令目标不匹配 允许。” 代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
<?xml version="1.0" encoding="utf-8"?>
但我一直收到错误信息
“与“[xX][mM][lL]”匹配的处理指令目标不匹配
允许。”
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal" >
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" >
<requestFocus />
</EditText>
<resources>
<string android:name="app_name"></string>
<string android:name="edit_message"></string>
<string android:name="button_send"></string>
<string android:name="action_settings"></string>
<string android:name="title_activity_main"></string>
</resources>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="text" >
<requestFocus />
</EditText>
<?xml version="1.0" encoding="utf-8"?>
我犯了什么错误吗?如果我这样做了,请通知我。是的,xml列表有几个错误(假设它只是一个文件) 删除这些字符串资源,并将它们放在项目的
res/values
文件夹中自己的strings.xml
文件中。此外,strings.xml文件也应该以它自己的
这不是错误,但您可能希望向这些字符串资源添加一些可能的文本标签,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string android:name="app_name">My Application Name</string>
<string android:name="edit_message"></string>
<string android:name="button_send">Send</string>
<string android:name="action_settings"></string>
<string android:name="title_activity_main"></string>
</resources>
我的申请名称
发送
别忘了用以下方式结束您的线性布局:
</LinearLayout>
删除两个requestFocus中的一个,我会假设每个布局应该只有一个(再次假设,您只想向我们显示一个文件,而不是多个文件)
并删除最后一行(这正是Eclipse所抱怨的):
您确实保留了xml文件第一行中的一个,但删除了最后一行中的一个,因为该类型的指令不关闭
让我知道这是否解决了你所有的问题。我不能确定它是否成功,因为我没有花时间打开我的另一台计算机并与Eclipse进行检查 1)在XML文件中使用或标记时,确保代码中不包含任何未声明的变量(在string.XML文件中)
2) 确保“R.java”文件反映了使用的所有变量
3) 重新构建项目并进行验证。请确保在
之前不应有任何字符。是的,在打开manifest.xml之前不应有任何字符。按ctrl+A
然后按ctrl+I
。它将自动格式化您的manifest.xml。如果语法正确,并且仍然出现此错误,则只需打开xml文件,右键单击并选择“验证”。1.确保您已在manifest文件的开始处写入。。。
2.确保文件前面不应有任何字符…XML文件在之前不应有任何其他字符,这三个可能导致此错误消息的原因中的每一个都包括在内。在我的例子中,我在XML布局文件中有两次这一行。我删除了它,它的工作。谢谢你的答复。我将更改代码,看看它是否有效。嗨。不幸的是,当我将关闭添加到“线性布局”选项卡时,仍然会出现错误。我收到这条消息“Element type“LinearLayout”后面必须跟属性规范“>”或“/>”。如果能得到任何帮助,我将不胜感激。谢谢。删除xmlns:tools=“”。只保留以xmlns:android=”开头的一行(如果仍然出现相同的错误,请在此处张贴最后一行作为注释)嗨。不幸的是,我仍然收到相同的错误。这是我的线性布局代码:我收到了描述中提到的这个异常,但它只发生了第一次。下次我尝试解析它时,一切都很好。如何解决,即使是第一次我也不应该得到它。这应该是一个注释1。确保你已经在startin上写了清单文件的g…2.确保在…之前不应有任何字符。。。。
</LinearLayout>
<requestFocus />
<?xml version="1.0" encoding="utf-8"?>