tags:

views:

553

answers:

2

Hi guys.

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.

+2  A: 

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:

  • Long Press is a recommeded interaction in the UI Guidelines, double touch is not.
  • It's what users expect; a user might not find a double touch action as they won't go looking for it
  • It's already handled in the API.
Dave Webb
Also typically the single tap action on a list item (to open or execute that item) deeply conflicts with whatever a double tap would be. So to be able to handle a double tap, you'd need to delay executing the single tap action until the double tap timeout passes, resulting in not very responsive UI.
hackbod
A: 

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.

k_day