A switch
is used on one variable - i.e. you have x
, which can equal 3,5 or 7. Then you switch x
and give several cases - what to do on each possible value (you can also have a default case, when none of the given values match). In your case, you're checking several different variables, so if ... else if ... else
is the correct method. You can, of course, make the radio boxes set a shared variable, which you can then switch
.
↧
Answer by Vladislav Zorov for basic android: syntax for switch statement instead of else-if
↧