If-else working, switch not

后端 未结 9 1826
一向
一向 2020-12-03 14:44

I am making an app that has a grid of images with text and each one opens a different activity. It works fine but just for design purposes I want to replace my if-else

9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 15:37

    You need to use break statement after eace case operations. In a switch-case statement if you dont use a break statement then all the cases after that specific one will be executed also

    case 0:
       textView.setText(R.string.zero);    
       break;
    

提交回复
热议问题