EDIT : I did some changes in your code and its working for me. onClick works for all the views. Here in your code, Rgroup's width is wrap_content, so if you have put RadioButtons inside the RG (which will completely overlap the RG), your clicks would be consumed by the RadioButtons (and not the Rgroup). I made the Rgroup's width to fill_parent and the click was getting executed. Here is my sample so that you can try it out.
<RadioGroup android:onClick="onRGClick" ndroid:text="RadioButton"
android:id="@+id/radioGroup1" android:layout_width="fill_parent" android:layout_height="wrap_content">
<RadioButton android:text="RadioButton" android:id="@+id/radioButton2" android:layout_width="wrap_content" android:layout_height="wrap_content"></RadioButton>
</RadioGroup>
And here is the Activity:
public class Hello extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onRGClick(View v){
Toast.makeText(this, "Test ", Toast.LENGTH_LONG).show();
}
Just click anywhere to the right of the RadioButton, and you will see the Toast.
Although for general purposes,OnCheckedChangeListener
is more useful.
Hope this helps you.