// 分类数组
String [] titles_ = {"测试1", "测试2", "测试3", "测试4", "测试5",};
// 初始化RadioGroup下的子元素
if (null != titles_) {
int size = titles_.length;
for (int i = 0; i < size; i++) {
RadioButton rdbtn = (RadioButton) LayoutInflater.from(empView_).inflate(R.layout.tabmenu_radiobutton, null);
rdbtn.setId(i);
rdbtn.setText(titles_[i]);
radioGroup_.addView(rdbtn);
}
}
tabmenu_radiobutton.xml如下:
xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/radioButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
tabmenu_style.xml
100dp
fill_parent
1.0
10dp
center
@null