Reputation: 6271
I am fairly new to android programming (but not to Java programming). I have a use case where a user clicks a 'Go >>' Button. Once the button is clicked, the text on the button changes to 'Done!' and the user can click the same button once he is 'done'.
I am wondering what is the best approach to implement this button behaviour... One approach that I can think of is to check for the button text and trigger appropriate action - is there a better way that you could recommend? Thanks!
Upvotes: 0
Views: 154
Reputation: 86948
The "best" approach is probably to check a boolean flag in the OnClickListener if the Button has already been clicked.
OnClickListener listener = new OnClickListener() {
boolean isFirstClick = true;
@Override
public void onClick(View v) {
if(isFirstClick) {
isFirstClick = false;
// Do something
}
}
}
An alternative approach is to check the value of the Buttons' text, but this is a few milliseconds slower.
Upvotes: 1