Reputation: 2370
I use the debugger to find that the value of townHallLvl stays 1 at the end
Please help
int townHallLvl = 1;
public void addTownHall(View v){
if (townHallLvl == 11) {
Toast.makeText(this, "You can't have more than Town Hall lvl 11!!!", Toast.LENGTH_SHORT).show();
return;
}
add(townHallLvl);
TextView townHallText = (TextView) findViewById(R.id.town_hall_lvl);
townHallText.setText(String.valueOf(townHallLvl));
}
public int add(int lvl){
int ans = lvl + 1;
return ans;
}
Upvotes: 0
Views: 55
Reputation: 41200
townHallLvl = add(townHallLvl);
You probably missed to assign back the value to townHallLvl.
Upvotes: 1