Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android onOptionsItemSelected avoid double click

How to avoid double click on my example, any solutions?

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.testing) {
                Dialog();
    return super.onOptionsItemSelected(item);
}
like image 656
waclaw Avatar asked Jun 12 '15 10:06

waclaw


1 Answers

There is many way to achieve this. I am telling only sample example.

Just create a boolean variable in Activity class.

Boolean isClicked = false;

and then

 @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.testing) {
    if (!isClicked){
//Change here as your flag is true
isClicked = true;
                    Dialog();
    }
        return super.onOptionsItemSelected(item);
    }

Then this dialog shows only one time. If any changes needed ask.

like image 88
Amsheer Avatar answered Sep 18 '22 10:09

Amsheer