Skip to content Skip to sidebar Skip to footer

Score Not Going Higher Than One Upon Correct Button Click? (java - Android Studio)

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). They

Solution 1:

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

finalint 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.

Post a Comment for "Score Not Going Higher Than One Upon Correct Button Click? (java - Android Studio)"