I'm making a game, which include two activities.
I have one
static class ModelGetter: public static int getPoint{int static point++;}.
When click a button in the first activity, the counter is incremented How can I avoid that in the same activity if I press twice the same button the counter don't incremente a counter two time, but just one?
Simple: inside the onClick, you need to disable the button:
yourButton.setEnabled(false);
So, when you retry to click it, nothing will happen, since the button is now disabled.
The comple code will be:
yourButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
v.setEnabled(false);
// increment what you want, or other stuff..
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With