I have tried the following code to differentiate single click and double click. Single click is ok. When I double click the imageview, code inside both the single click and doub
btn.setOnClickListener(new View.OnClickListener() {
volatile int i = 0;
@Override
public void onClick(View v) {
i++;
Handler handler = new Handler();
Runnable r = new Runnable() {
@Override
public void run() {
if (i == 1) {
//single click logic
i = 0; //set to zero
}
}
};
if (i == 1) {
handler.postDelayed(r, 300);
} else if (i == 2) {
handler.removeCallbacks(r);
i = 0;
//Double click logic
}
}
}
);