【发布时间】:2013-09-02 01:13:28
【问题描述】:
我从一本名为《Android Programming The Big Nerd Ranch Guide》的书中开始学习 Android 编程,这些就是其中一个示例。但是,我遇到了错误。
错误是:
- 1。解析 XML 时出错:文档元素后出现垃圾。
- 2。文档中根元素之后的标记必须格式正确。
- 3.在布局文件中发现意外的文本:“””
<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"
tools:context=".QuizActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world" />
</RelativeLayout>
<!-- Error 1 and 2 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="24dp"
android:text="@string/question_text" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<!-- Error 3 -->
android:text="@string/true_button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/false_button" />
</LinearLayout>
</LinearLayout>
【问题讨论】:
-
对于第三个错误,如果你只是有
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/true_button" />,那么它也显示错误? -
是的。我刚刚在 stackoverflow 上添加了注释以显示错误在哪里。
-
查看答案并评论任何进一步的问题。
标签: android