Eclipse 抱怨布局 xml 中的元素无用 [英] Eclipse complains about uselessness of elements in layout xml

查看:18
本文介绍了Eclipse 抱怨布局 xml 中的元素无用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动视图.一个滚动视图只能包含一个元素,所以我将我的 RadioGroup 和下面的按钮(用作占位符)放在 TableLayout 中.

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>

现在 Eclipse 向我显示一个 xml 警告:RadioGroup 布局或其 TableRow 父级可能无用".他们怎么可能没用?首先,我需要 radiogroup 来访问选定的单选按钮:

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);

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

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?

推荐答案

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

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

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

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

在此处用作无用的父级,因此 Eclipse 会向您显示

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

这篇关于Eclipse 抱怨布局 xml 中的元素无用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆