Is it possible to use an OR statement in a switch/case structure? Suppose I want to do the same thing when clicking on two different items.
I tried
(case R.id.bOne || case R.id.tvOne):
and
case (R.id.bOne || R.id.tvOne):
But none of them seem to work..
This will work:
case R.id.bOne:
case R.id.tvOne:
// do your stuff
Try this:
switch(id){
case R.id.bOne:
case R.id.tvOne:
// do your stuff here
break;
case R.id.x:
// do your stuff here
break;
default:
// do your stuff here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With