Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to cancel the value attached to the previously checked radio button when new one is been press
    text
    copied!<p>Hey guys please I need help on this.</p> <p>I have a quiz app where I am parsing questions from xml files. I have thousands of questions coming from different <code>subject.xml</code> and <code>subjectanswer.xml</code> when parsing. I generated a random variable that picks different questions at random and also the answers are picked along side the questions... </p> <p>So this is my problem when the answers are picked I want to compare it with the answer the user will select. If the user selects, lets say <code>A</code> and <code>A</code> corresponds with the answer from the parsed xml I want <code>sum = sum + 10</code>. In my radio button lets say user first selects the correct answer -> <code>sum = sum + 10</code>. Now if the user change her mind and chose another answer... Sum remains as 10... I want the value attached to the previous already selected radio button to be cancel when another radio button is clicked...</p> <p>I hope you guys get the problem. Please help me out guys..</p> <pre><code>@Override public void onCheckedChanged(RadioGroup arg0, int arg1) { switch (arg1) { case (R.id.a1): if (a1.isChecked()) if (what.equalsIgnoreCase("A")) { sumUp = sumUp + 10; } break; case (R.id.b1): if (b1.isChecked()) if (what.equalsIgnoreCase("B")) { sumUp = sumUp + 10; } break; case (R.id.c1): if (c1.isChecked()) if (what.equalsIgnoreCase("C")) { sumUp = sumUp + 10; } break; case (R.id.d1): if (d1.isChecked()) if (what.equalsIgnoreCase("D")) { sumUp = sumUp + 10; } break; } String sumUptoString = Integer.toString(sumUp); tv3.setText(sumUptoString); } </code></pre> <p>The <code>what</code> variable is the original answer I parsed out from the <code>subjectanswer.xml</code></p>
 

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