I want to notify a user that he has reached a minimum value. The value is set via the button click. If he continues to click on a button, when a minimum value has been reached, Toasts start appearing and queuing so it takes a long time for all to disappear.
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
if (value < MIN_VALUE) {
Toast.makeText(MyActivity.this, "You have reached the minimum value",
Toast.LENGTH_SHORT).show();
}
});
How can I make only 1st toast to appear on button click? This way if a user keeps clicking the button, no other toasts will appear.
Add a flag that indicates whether the button was already pressed or not: