0

我有一个滚动视图。滚动视图只能包含一个元素,因此我将 RadioGroup 和下面的按钮(用作占位符)放在 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>

现在 Eclipse 向我显示了一个 xml 警告:"The RadioGroup layout or its TableRow parent is possibly useless". 他们怎么可能没用?首先,我需要 radiogroup 来访问选定的单选按钮:

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

并且 TableLayout 是必需的,因为我在 ScrollView 中只能有一个元素。由于下面的占位符按钮,我选择了 TableView。那有什么问题呢?

4

3 回答 3

1

我认为这是因为在表格布局中使用表格行元素作为父级。

您可以从 xml 中删除元素,因为已将行添加到表格布局中。

在这里用作无用的父级,因此 Eclipse 向您显示一个无用父级的警告

于 2012-01-02T09:24:16.377 回答
0

我认为当您仅使用表格中的一行时会发生这种情况,而当我使用两行或更多行时,消息就会消失。(为什么在一个表中只放了一行,那么表本身就已经是一行了,这一定是背后的思想)。

于 2014-04-08T09:14:32.937 回答
0

我认为该表是无用的,因为简单的 LinearLayout 也应该完成这项工作。另请仔细阅读:possibly useless并不意味着它没有用。

于 2012-01-02T09:09:57.907 回答