title: Multiple Radio group in a single Activity
body: <p>I'm Developing an android app in which the Questionnaire activity contains radio buttons for every question.And I've designed the activity in Linear layout.So now i wanted to check whether the user as answered all Questions.The problem I'm facing is in the public void OnClick(View v)help me in modifying the java code.
  <img src="https://i.stack.imgur.com/pl8WZ.png" alt="Here is the view of my Activity"></p>
  
  <pre><code>&lt;RadioGroup
      android:id="@+id/Mquestion1"  
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"&gt;
  &lt;RadioButton
      android:id="@+id/radioButton1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_1_rb1" /&gt;
  
  &lt;RadioButton
      android:id="@+id/radioButton2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_1_rb2" /&gt;
  
  &lt;RadioButton
      android:id="@+id/radioButton3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_1_rb3" /&gt;
  &lt;/RadioGroup&gt;
  &lt;TextView
      android:id="@+id/textView3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_2_view"
      android:textAppearance="?android:attr/textAppearanceSmall" /&gt;
  &lt;RadioGroup
  android:id="@+id/Mquestion2"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"&gt;
  &lt;RadioButton
      android:id="@+id/radioButton4"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_2_rb1" /&gt;
  
  &lt;RadioButton
      android:id="@+id/radioButton5"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_2_rb2" /&gt;
  
  &lt;RadioButton
      android:id="@+id/radioButton6"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_2_rb3" /&gt;
  &lt;/RadioGroup&gt;
  &lt;TextView
      android:id="@+id/textView4"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_3_view"
      android:textAppearance="?android:attr/textAppearanceSmall" /&gt;
  &lt;RadioGroup
  android:id="@+id/Mquestion3"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"&gt;
  &lt;RadioButton
      android:id="@+id/radioButton7"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_3_rb1" /&gt;
  
   &lt;RadioButton
      android:id="@+id/radioButton8"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_3_rb2" /&gt;
  
   &lt;RadioButton
      android:id="@+id/radioButton9"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/MQ1_3_rb3" /&gt;
   &lt;/RadioGroup&gt;
   &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="44dp" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          style="?android:attr/buttonStyleSmall"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:onClick="OnClickListener"
          android:text="@string/MQ1_next" /&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Here is the java code</p>
  
  <pre><code>  public class ManagerQuestionnaire1 extends Activity
   {
  
  Button next;
  RadioGroup rg1;
  RadioGroup rg2;
  RadioGroup rg3;
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_manager_questionnaire1);
      final RadioGroup    rg1=(RadioGroup)findViewById(R.id.Mquestion1);
       final RadioGroup   rg2=(RadioGroup)findViewById(R.id.Mquestion2);
       final RadioGroup   rg3=(RadioGroup)findViewById(R.id.Mquestion3);
      Button next=(Button)findViewById(R.id.button1);
              next.setOnClickListener(new View.OnClickListener()
              {
                  public void OnClick(View v) \\The error I'm getting here is REMOVE method'OnClick'
                  {
  
                      if((rg1.getCheckedRadioButtonId()!=R.id.radioButton1 || rg1.getCheckedRadioButtonId()!=R.id.radioButton2 || rg1.getCheckedRadioButtonId()!=R.id.radioButton3)||(rg2.getCheckedRadioButtonId()!=R.id.radioButton4 || rg2.getCheckedRadioButtonId()!=R.id.radioButton5 || rg2.getCheckedRadioButtonId()!=R.id.radioButton6)||(rg3.getCheckedRadioButtonId()!=R.id.radioButton7 || rg3.getCheckedRadioButtonId()!=R.id.radioButton8 || rg3.getCheckedRadioButtonId()!=R.id.radioButton9))
                      {
                           AlertDialog alert= new AlertDialog.Builder(ManagerQuestionnaire1.this).create();
                           alert.setTitle("Exception:Complete the Questions");
                           alert.setMessage("Please ensure all Questions are answered");
                      }
                      else    
                      {
                             Intent intent = new Intent(ManagerQuestionnaire1.this, ManagerQuestionnaire2.class);
                              startActivity(intent);
                      }
                  }
  
                  @Override
                  public void onClick(View v) 
                  {
                      // TODO Auto-generated method stub
  
                  }
  
  
      });
   }
  </code></pre>