Do you know about how to detect two touches/taps on a ListView
?
I am trying to have the following method called when double touched:
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
}
Thanks in advance.
Why aren't you using a Long Touch? Or are you using that already for something else? The advantages over a long touch over a double touch:
Edit:
See it here: Involving CountDownTimer: https://github.com/NikolaDespotoski/DoubleTapListView Involving Handler: http://code.google.com/p/double-tap-listview-handler/ https://github.com/NikolaDespotoski/DoubleTapListViewHandler My brief explaination: http://mobisys.in/blog/2012/01/how-to-detect-double-taps-on-listview-items-in-android/
If you are set on using a double tap in your UI, you could always save state in your Actvity or other container.
A simple implementation would be storing the time the touch was registered, and comparing against that on the next touch event to determine if the time lapsed since the second touch falls with in whatever range you are defining a double tab to mean.
I think that a double tap on a ListView can be totally valid, particularly if it is done over an unoccupied area. For instance I have a diary application listing actions for today. This is already so that long presses allow actions to be edited or deleted. But left / right touch gestures are used to quickly move to the previous / next day, and a double tap is a shortcut to get back to "today". Is that intuitive? Well, close enough, I think.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With