Monday 15 July 2013

android - Click twice to check Radio Button? -


I am trying to create the probe app and I'm using the radio button for one of the options, B, C, D. I'm trying to calculate the result - & gt; For example, when one increment press 1, when the increase of B is pressed 2 and on this I was using the radio group for the first time, but I understood that the user tries to change the answer to his question from one, then the increase will not be expected as the results 3, 2 will be expected. So I switched to the radio button and I tried the following code:

  rb1.setOnCheckedChangeListener (new android.widget.CompoundButton.OnCheckedChangeListener () {@Override Public Zero onCheckedChanged (CompoundButton buttonView, Boolean IsChecked) {i ++, if (rb2.isChecked ()) {i--; rb2.setChecked (wrong);}}}); Rb2.setOnCheckedChangeListener (new android.widget.CompoundButton.OnCheckedChangeListener) {@CheckedChanged on Public Zero (compound button button view, boolean hackcake) {i ++; if (rb1.isChecked ()) {i--; rb2.setChecked (False);}}});   

And now the second radio button sequence has to be checked twice. Does it have a bug and it may decide I need the button to change the state after the first click. All ideas and advice will be welcome Thanks.

You can change your code to use a switch statement (as suggested in a comment) But if you want to continue doing what you have, and to answer your question, for Rb2 in your code, you are saying that if rb1 is checked then rb2 is set to false has been done. Therefore, if you click RB1 (and it is now checked / pushed) and if you click it unselected RB2 for the first time, it keeps checking for 2 times.

Then sticking to its coding style and process:

  Public Zero (compounded button button view, check boolean) on check-in {i ++; If (rb1.isChecked ()) {i--; Rb2.setChecked (wrong); }}   

should be:

  checked on public invalid (compounded button button view, boolean is checked) {i ++; If (checked & amp; rb 1.is check ()) {i--; Rb1.setChecked (wrong); } Rb2.setChecked (isChecked); }   

Make a similar change in your RB1 method.

No comments:

Post a Comment