Search code examples
androidxmlandroid-layoutscrollviewandroid-tablelayout

Eclipse complains about uselessness of elements in layout xml


I have a scrollview. A scrollview can only contain one element so I put my RadioGroup and the button below (which acts as a placeholder) inside a TableLayout.

 <ScrollView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal" >

            <TableLayout
                android:layout_width="300sp"
                android:layout_height="wrap_content" >

                <TableRow>
                    <RadioGroup
                        android:id="@+id/radioStateChoice"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:orientation="vertical" >

                        <RadioButton
                            android:id="@+id/radioW"
                            style="@style/CheckboxRadioStyle"
                            android:checked="true"
                            android:text="@string/wien" />

                        <RadioButton
                            android:id="@+id/radioNoe"
                            style="@style/CheckboxRadioStyle"
                            android:text="@string/noe" />

                        <RadioButton
                            android:id="@+id/radioOoe"
                            style="@style/CheckboxRadioStyle"
                            android:text="@string/ooe" />

                        <!-- there are usually more radio buttons -->
                        <!-- I have shortened it to keep the example smaller -->
                    </RadioGroup>
                </TableRow>

                <TableRow>
                    <Button
                        android:layout_width="60sp"
                        android:layout_height="50sp"
                        android:visibility="invisible" />
                </TableRow>
            </TableLayout>
        </ScrollView>

Now Eclipse shows me an xml warning: "The RadioGroup layout or its TableRow parent is possibly useless". How can they be useless? First of all, I need the radiogroup to access the selected radio button:

        int selectedRadioId = radioGroup.getCheckedRadioButtonId();
        RadioButton selectedRadioButton = (RadioButton)findViewById(selectedRadioId);

And the TableLayout is needed due to the fact, that I can only have one element inside the ScrollView. I chose a TableView because of the placeholder button below. So what's wrong with that?


Solution

  • I think it's because of using table row element as parent of in table layout.

    you can just remove elelment from xml because has add the row to Table layout.

    Using as a parent of is Useless here so eclipse show you a warning of an useless parent for