Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is the solution I came up with.</p> <pre><code>radioGroup1 = (RadioGroup) findViewById(R.id.radioGroup1); radioGroup2 = (RadioGroup) findViewById(R.id.radioGroup2); RadioButton[] tempradbutton1 = { (RadioButton) findViewById(R.id.radio1), (RadioButton) findViewById(R.id.radio2) }; RadioButton[] tempradbutton2 = { (RadioButton) findViewById(R.id.radio4), (RadioButton) findViewById(R.id.radio5) }; radbutton1 = tempradbutton1; radbutton2 = tempradbutton2; for (int i = 0; i &lt; radbutton1.length; i++) { radbutton1[i].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub radioGroup2.clearCheck(); } }); radbutton2[i].setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub radioGroup1.clearCheck(); } }); } </code></pre> <p>Rather then using <strong>setOnCheckedChangeListener</strong>, use <strong>onClickListener</strong> for every radiobutton exist on the radiogroup.</p> <p>XML:</p> <pre><code>&lt;RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" &gt; &lt;RadioButton android:id="@+id/radio1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton" /&gt; &lt;RadioButton android:id="@+id/radio2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton" /&gt; &lt;/RadioGroup&gt; &lt;RadioGroup android:id="@+id/radioGroup2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/radioGroup1" &gt; &lt;RadioButton android:id="@+id/radio4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton" /&gt; &lt;RadioButton android:id="@+id/radio5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton" /&gt; &lt;/RadioGroup&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload