我有一個滾動視圖。 scrollview只能包含一個元素,所以我把我的RadioGroup和下面的按鈕(它充當佔位符)放在TableLayout中。Eclipse抱怨佈局xml中的元素無用
<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需要由於這樣的事實,那我只能有滾動型中的一個元素。由於下面的佔位符按鈕,我選擇了一個TableView。那有什麼問題呢?
你說得對,我可以省略TableRows。不知道這是有效的。 – Bevor 2012-01-02 09:44:01
你能說出兩三句話嗎?真的很難理解永無止境的文字。 – WarrenFaith 2012-01-02 09:47:55
你到底明白了什麼?我只是省略了TableRows,所以我刪除了所有的和 這幾行,這似乎正常工作。 –
Bevor
2012-01-02 10:01:00