Quantcast
Channel: basic android: syntax for switch statement instead of else-if - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Jason Robinson for basic android: syntax for switch statement instead of else-if

$
0
0

What the people above me said is correct, but for the sake of using a switch statement for the hell of it, you could set an OnCheckedChangedListener on your RadioGroup, then use a class like this:

private class MyCheckedChangedListener implements OnCheckedChangeListener {@Overridepublic void onCheckedChanged( RadioGroup group, int checkedId ) {    switch (checkedId) {        case R.id.radio15:            percentage = 15f;            break;        case R.id.radio18:            percentage = 18f;            break;        case R.id.radio20:            percentage = 20f;            break;    }}

}


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>