スクロールビューがあります。スクロールビューに含めることができる要素は1つだけなので、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"
。どうして役に立たないのでしょうか?まず、選択したラジオボタンにアクセスするためにラジオグループが必要です。
int selectedRadioId = radioGroup.getCheckedRadioButtonId();
RadioButton selectedRadioButton = (RadioButton)findViewById(selectedRadioId);
また、ScrollView内に含めることができる要素は1つだけであるため、TableLayoutが必要です。下のプレースホルダーボタンがあるため、TableViewを選択しました。それで、それの何が問題になっていますか?