I know there are some questions like this , but none of the answers could solve my problem. So I'm gonna ask myself. How can I solve this problem? Sorry for don't specify more, I'm starting coding
Asked
Active
Viewed 77 times
0

Arthur Moresche
- 43
- 1
3 Answers
0
A way of solving the problem would be to make the variable score1 a field variable, so after the declaration of the java class make a variable with private visibility and then increment that variable.
public class Test{
private int score1;
//Constructor for the class for setting the variable.
public Test(){
score1 = 0 //Whatever the start value should be
}
}
All in all you now have a variable which can be "seen" from the inner class of the actionlistener.
Hope that helps :)

Mark
- 41
- 6
0
replace
int score1=sharedPreferences.getInt("score",DEFAULT);
with
final int score1=sharedPreferences.getInt("score",DEFAULT);
or instead you declare score as a class variable
public class someclass{
int score1;
//here comes the rest of the code
}
good luck

Mohammed Elrashied
- 332
- 3
- 13
-
Didn't work. I declare it as public and the same problem continues. I can't define it as final because its a Preference – Arthur Moresche Mar 18 '16 at 21:54