Score not going higher than one upon correct button click? (Java - Android Studio)

后端 未结 1 1114
野的像风
野的像风 2021-01-27 09:01

In the program, I have two random values (loadG4 and rbvalue). These values are set to 4 buttons, rbvalue to 3 and loadg4 to one (loadg4 overrides on of the rbvalue buttons). Th

相关标签:
1条回答
  • 2021-01-27 09:32

    The issue is that you are creating the loadG4 variable in multiple places with different scopes. When you do this :

    final int loadG4 = GenerateG4.nextInt(10);
    

    You are creating a new variable G4 which exists separately from your instance variable loafG4 which was created first (and never changes ). Hence, you are always comparing against a constant value.

    Also, you are changing the value of the button text inside onClickListener, that is why your button labels keep changing on pressing them.

    0 讨论(0)
提交回复
热议问题