"RadioGroup" must be followed by either attribute specifications, ">" or "/>"

272 views Asked by At

I am having been following a beginners tutorial and I have encountered this error which i can't seem to understand or solve.

<?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:orientation="vertical" >

    <EditText android:text="" 
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <LinearLayout android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:weightSum="2"     
        android:orientation="horizontal" >
        <TextView android:id="@+id/tvStyle"
            android:layout_width="fill_parent"  
            android:layout_height="wrap_content"
            android:layout_weight="1"  
            android:gravity="center"  
            android:textStyle="bold"
            android:text="Style" />
        <TextView android:id="@+id/tvGravity" 
            android:layout_width="fill_parent" 
            android:gravity="center" 
            android:layout_height="wrap_content" 
            android:layout_weight="1"
            android:textStyle="bold"
            android:text="Gravity" />
    </LinearLayout>

    <LinearLayout android:layout_width="fill_parent"     
        android:layout_height="wrap_content"
        android:weightSum="2" 
        android:orientation="horizontal" >

        <RadioGroup android:orientation="vertical" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:layout_weight="1"
            android:id="@+id/rgStyle"

            <RadioButton  android:id="@+id/rbNorm"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Normal" />
            <RadioButton  android:id="@+id/rbIta"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Italic" />   
            <RadioButton  android:id="@+id/rbBold"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Bold" />  
        </RadioGroup>

        <RadioGroup android:orientation="vertical" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"     
            android:layout_weight="1"
            android:id="@+id/rgGravity"
            <RadioButton  android:id="@+id/rbLeft"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Left" />    
            <RadioButton  android:id="@+id/rbCenter"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Center" />    
            <RadioButton  android:id="@+id/rbRight"  
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Right" />
        </RadioGroup>       

    </LinearLayout>

    <TextView  android:id="@+id/tvChange" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:textSize="20dp"
        android:text="Type In Text And Press Button Below" />

    <Button  android:id="@+id/bGenerate" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Generate" />

</LinearLayout>

I keep getting the error-'Error parsing XML: not well-formed (invalid token)'on the 34th line and 'Element type "RadioGroup" must be followed by either attribute specifications, ">" or "/>"' on the next line.


Help me please I'm a newbie

3

There are 3 answers

0
Itzik Samara On

mate you cant use /> and </RadioGroup> choose one of them.. check the example here RadioGroup example

1
Felix On

Thanks I found out that the error were due to the way i formatted the code...i corrected it by simply using Ctr+Shift+F

0
user4989692 On

You were missing the > from the following places

<RadioGroup android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"     
    android:layout_weight="1"
    android:id="@+id/rgGravity"

and

<RadioGroup android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" 
    android:layout_weight="1"
    android:id="@+id/rgStyle"