0
如何將所有動態創建的收音機按鈕分組到一個組中?Android TableLayout組動態收音機按鈕
while (cursor.moveToNext()) {
TableRow row = new TableRow(this);
// CheckBox chk = new CheckBox(this);
RadioButton radioBtn = new RadioButton(this);
// chk.setText(cursor.getString(cursor.getColumnIndex("from_text")));
radioBtn.setText(cursor.getString(cursor.getColumnIndex("from_text")));
radioBtn.
row.addView(radioBtn);
table.addView(row);
}
的Xml
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TableLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/myTable"/>
</LinearLayout>