简体   繁体   English

在此行发现多个注释:-文档中根元素之后的标记必须格式正确

[英]Multiple annotations found at this line: - The markup in the document following the root element must be well- formed

I'm new to coding and want to learn really bad. 我是编码新手,想学习真的很烂。
I am on the developer.android.com site to teach myself. 我在developer.android.com网站上自学。
Unfortunately, I have run into a quagmire and can't get past this code. 不幸的是,我陷入了泥潭,无法摆脱这段代码。
Please, help. 请帮忙。 What am I doing wrong? 我究竟做错了什么?
If you want to look at the exercise here is the address: 如果您想看一下练习,这里是地址:
http://developer.android.com/training/basics/firstapp/building-ui.html#Button http://developer.android.com/training/basics/firstapp/building-ui.html#Button

<?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/edit_message"
        android:layout_weight="1"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:hint="@string/edit_message" />
     <Button
        android:layout_width="wrap_content"
            android:layout_height="wrap_content"
    android:text="@string/button_send" />

</LinearLayout>

Your issue is here: 您的问题在这里:

<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" />

Note that you have 注意你有

/> 

This closes the linear layout tag. 这将关闭线性布局标签。 It should look like this: 它看起来应该像这样:

<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" >

without the closing /

Note: 注意:

If you are on linux, a REALLY easy way to determine if you've copied code from tutorials correctly is using Meld. 如果您使用的是Linux,确定Melt是从教程中正确复制代码的一种非常简单的方法。 I copied your code into a file name 1, the tutorial code in a file named 2 and did "meld 1 2", the resultant UI displayed exactly what your error was without my even having to think 我将您的代码复制到文件名1中,将教程代码复制到名为2的文件中,并“融合了1 2”,结果UI完全显示了您的错误,而我甚至都无需考虑

Edit: 编辑:

First - meld for windows; 首先-Windows的融合;

http://meldmerge.org/ http://meldmerge.org/

For your issue with the param: 对于参数问题:

@String/edit_message

You need to define this value in the string resources of your application. 您需要在应用程序的字符串资源中定义此值。 The following is taken from 以下摘自

http://developer.android.com/guide/topics/resources/string-resource.html http://developer.android.com/guide/topics/resources/string-resource.html

FILE LOCATION:
res/values/filename.xml  // in oyur case this will likely be Strings.xml

The filename is arbitrary. The <string> element's name will be used as the resource ID.

COMPILED RESOURCE DATATYPE:
Resource pointer to a String.

RESOURCE REFERENCE:
In Java: R.string.string_name
In XML:@string/string_name

SYNTAX:
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string
        name="string_name"  // in your case this will be name="edit_message"
        >text_string</string>
</resources>

If the file doesn't exist, you can create it in the location: 如果该文件不存在,则可以在以下位置创建它:

/res/values/strings.xml

Define your values and such there and everything should be fixed. 定义您的值,并在那里进行固定。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 解析XML时出错:文档元素之后的垃圾;必须正确形成根元素后面的文档中的标记 - Error parsing XML: junk after document element;The markup in the document following the root element must be well- formed Android清单。 根元素后面的文档中的标记必须格式正确 - Android Manifest . The markup in the document following the root element must be well formed 错误:根元素后面的文档中的标记必须格式正确 - Error: The markup in the document following the root element must be well-formed (webview)根元素后面的文档中的标记必须格式正确 - (webview)The markup in the document following the root element must be well-formed 根元素后面的文档中的标记必须格式正确吗? - The markup in the document following the root element must be well-formed? 根之后的文档中的标记必须格式正确 - the markup in the document following the root must be well formed 必须很好地形成根元素后面的文档中的标记。 虽然只有一个根元素 - The markup in the document following the root element must be well formed. Although there is just one root element 根目录后面的文档中的标记必须格式正确(不能删除额外的行) - The markup in the document following the root must be well-formed (Cannot delete extra line) 清单错误根元素后面的文档中的标记必须格式正确 - Manifest error The markup in the document following the root element must be well-formed 错误! Android中的编程-Java开发人员-根元素后的文档中的标记必须格式正确 - ERROR ! in Android - java developer - The markup in the document following the root element must be well-formed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM