错误:匹配“[xX] [mM] [lL]”的处理指令目标不允许 [英] ERROR:The processing instruction target matching "[xX][mM][lL]" is not allowed
问题描述
<?xml version =1.0encoding =utf-8?>
但是我收到错误消息
匹配[xX] [mM] [lL]的处理指令目标不允许
。
这是代码:
<?xml version =1.0encoding =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.0encoding =utf-8?>
我犯了错误吗?如果我这样做,请通知我。
是的,xml列表有几个错误(假设它只是一个文件)。
删除这些字符串资源,并将它们放在自己的项目的 strings.xml
文件中> res / values 文件夹。此外,strings.xml文件也应该以自己的<?xml version =1.0encoding =utf-8?>
<?xml version =1.0encoding =utf-8?>
< 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>
这不是一个错误,但您可能需要为这些字符串资源添加一些可能的文本标签,如这个:
<?xml version =1.0encoding =utf-8?>
< 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>
不要忘记关闭您的LinearLayout:
< / LinearLayout>
删除两个requestFocus中的一个,我假设每个布局应该只有一个(假设再次,你只是想给我们显示一个文件而不是多个文件)。
< requestFocus />
并删除最后一行(这是Eclipse所抱怨的):
<?xml version =1.0encoding =utf-8?>
您确实保留了xml文件的第一行,但是将其从最后一行,因为该类型的指令不关闭。
让我知道这是否解决了你所有的问题。我不能确定它是因为我没有花时间打开我的其他电脑并检查与Eclipse。
I am using eclipse to program an android app and i came to a halt. I tried closing my code with
<?xml version="1.0" encoding="utf-8"?>
But I keep getting the error message
"The processing instruction target matching "[xX][mM][lL]" is not allowed."
Here's the code:
<?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"?>
Did I make any mistakes? If I did, please inform me.
Yes, that xml listing has several mistakes (assuming it's meant to be only one file).
Remove those string resources and place them in their own strings.xml
file inside your project's res/values
folder. Furthermore, that strings.xml file should also start with its own <?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<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>
This is not an error, but you may want to add some possible text labels to those string resources like this:
<?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>
Don't forget to close your LinearLayout with:
</LinearLayout>
Remove one of the two requestFocus, I would assume that you should only have one per layout (assuming that again, you only meant to show us only one file and not multiple files).
<requestFocus />
And remove that last line (that is what Eclipse is complaining about):
<?xml version="1.0" encoding="utf-8"?>
You do keep the one from the very first line of your xml file, but you remove the one from the last line, because that type of directive doesn't close.
Let me know if this fixed all your problems. I can't be sure it did because I didn't take the time to open my other computer and check with Eclipse.
这篇关于错误:匹配“[xX] [mM] [lL]”的处理指令目标不允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!