Switch statement just returning the last case

前端 未结 4 832
[愿得一人]
[愿得一人] 2021-01-24 00:52

Switch statment fix: The switch statement is only returning the last case i.e case 4, \"#0R0dfdf0FF\". how can i fix this so the text view shows the the one cli

4条回答
  •  佛祖请我去吃肉
    2021-01-24 01:37

    Fall Through.

    You have to add the break.

    case 0:
              mColor.setText("#000000");
              break;
    

    You can find that in docs

    The break statements are necessary because without them, statements in switch blocks fall through: All statements after the matching case label are executed in sequence, regardless of the expression of subsequent case labels, until a break statement is encountered.

提交回复
热议问题