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
Try this.
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
}
}
};
if (i == 1) {
handler.postDelayed(r, 150);
} else if (i == 2) {
handler.removeCallbacks(r);
i = 0;
//Double click logic
}
}
}
);
Or you can check DOUBLE-TAP example from following URL. that is used in listView. i hope it is useful for you.
https://nodeload.github.com/NikolaDespotoski/DoubleTapListView/zip/master