I'm trying to set my counter in parse to not go below zero when the score is being decremented, at the moment it can go to negative numbers. How can I set the minimum limit to be zero?
This is what I've managed to do so far:
btnPointTeamD.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.increment("team_d_score");
object.saveInBackground();
}
});
btnMinusTeamC.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.increment("team_c_score", -1);
object.saveInBackground();
}
});
See Question&Answers more detail:os