簡體   English   中英

Android - XML文件中的錯誤

[英]Android - Error in XML files

所以我正在構建一個項目,但是我的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>

希望這可以幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM