title: How to count yes and no answers using radio buttons
body: <p>I don't know if this was asked or not (I searched a little but no result) but I'm kinda time pressed and I need help
  I've been developing an application in Android and I've only started under this platform for 3 months</p>
  
  <p>I have a choice test with different questions and yes and no answers using radio buttons</p>
  
  <p>I want to count the "yes" answers but even like this if I put r1.isChecked() instead of for and buttons[i].isChecked() it counts the clicks</p>
  
  <p>Here is what I tried until now and I get force close everytime I click on the first radiobutton  <code>RadioButton[]buttons={rb1, rb3,rb5} ;</code></p>
  
  <pre><code>public void onClick(View view){
  
  
  
          checkStates(buttons);
  
  
  }
  private void  checkStates(RadioButton[] buttons) { 
  
            for (int i=0; i&lt;buttons.length; i++) {
               if (buttons[i].isChecked()) 
                  da++;}
  tv.setText("Result:"+yes);
      }
  </code></pre>
  
  <p>How can I tell my appplication that the radiobuttons are already checked and no need to increment it on a second click (on the same radio button?)</p>
  
  <p>Is there a way to count using the ids or the name of the radiobuttons?</p>
  
  <p>If so how should I do it? Some tutorials (I love them) and tips would help a lot.</p>
  
  <p>Thanks.</p>