所以我正在构建一个项目,但我的 R.Java 不知何故被删除(原因?),它显示 R 无法解析为变量,现在该怎么办?我的布局中也没有 main.out.xml,所以没有问题。
另一个问题是我的 XML 文件在底部的两行中分别显示了这些错误:
1 - 解析 XML 时出错,未找到元素(不知道这是什么意思。)
2 - XML 文档结构必须在同一实体内开始结束。(找不到未关闭的标签,帮帮我!)
这是我遇到问题的 XML 文件的代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/imgthing"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10" >
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@drawable/imgthing"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="TextView" />
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/imgthing"
android:orientation="horizontal"
android:weightSum="2" >
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="TextView" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
</LinearLayout>
此外,当我在图形布局中查看它时,其中没有可见的单选按钮。如果重要的话,我有一个白色背景。 编辑:第二个错误消失了,重新发布代码,它只有第一个错误。
最佳答案
你忘了关闭你的父布局,关闭它就可以了!
在文件末尾添加
</LinearLayout>
希望这对您有所帮助!
关于java - Android - XML 文件错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20903401/