to implement multiple row multiple column use the following code below
xml to be used
<RadioGroup
android:id="@+id/first_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fullName_menu"
android:orientation="horizontal">
<RadioButton
android:id="@+id/btn1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector."
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
<RadioButton
android:id="@+id/btn2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector."
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
<RadioButton
android:id="@+id/btn3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector."
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
</RadioGroup>
<RadioGroup
android:id="@+id/second_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/first_group"
android:orientation="horizontal">
<RadioButton
android:id="@+id/btn4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector."
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
<RadioButton
android:id="@+id/btn5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector"
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
<RadioButton
android:id="@+id/btn6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_weight="1"
android:button="@null"
android:fontFamily="sans-serif-light"
android:paddingLeft="5dip"
android:background="@drawable/button selector"
android:textColor="#ffffff"
android:textSize="14sp" >
</RadioButton>
</RadioGroup>
for the background use the following xml
button selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/state1" android:state_checked="true"/>
<item android:drawable="@drawable/state2" android:state_checked="false"/>
</selector>
use the following in your java class
RadioGroup mFirstGroup, mSecondGroup;
mFirstGroup = (RadioGroup)findViewById(R.id.first_group);
mSecondGroup = (RadioGroup)findViewById(R.id.second_group);
mFirstGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId != -1 && isChecking) {
isChecking = false;
mSecondGroup.clearCheck();
mCheckedId = checkedId;
switch (mCheckedId) {
case R.id.btn1:
Toast.makeText(getActivity(), "type1", Toast.LENGTH_SHORT).show();
Log.e("type1","type1");
break;
case R.id.btn2:
Toast.makeText(getActivity(), "type2", Toast.LENGTH_SHORT).show();
Log.e("type2","type2");
break;
case R.id.btn3:
Toast.makeText(getActivity(), "type3", Toast.LENGTH_SHORT).show();
Log.e("type3","type3");
break;
}
}
isChecking = true;
}
});
mSecondGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId != -1 && isChecking) {
isChecking = false;
mFirstGroup.clearCheck();
mCheckedId = checkedId;
switch (mCheckedId) {
case R.id.btn4:
Toast.makeText(getActivity(), "type4", Toast.LENGTH_SHORT).show();
Log.e("type4","type4");
break;
case R.id.btn5:
Toast.makeText(getActivity(), "type5", Toast.LENGTH_SHORT).show();
Log.e("type5","type5");
break;
case R.id.btn6:
Toast.makeText(getActivity(), "type6", Toast.LENGTH_SHORT).show();
Log.e("type6","type6");
break;
}
}
isChecking = true;
}
});
thats it !!!!!! good luck