Laura
Laura

Reputation: 2773

Multi-touch two fingers taps

I have to implement a two fingers tap.

For example I have a listView with multiple items, which already have a click listener for each row and touch listener. Now I have to do something if the user put two fingers on a row.

How can I do this?

Any suggestion is appreciated.

Upvotes: 4

Views: 9207

Answers (3)

Matthieu
Matthieu

Reputation: 16387

I believe just the gesture API only support single touch.

You basically have to override `onTouchEvent, and play with e.getPointerCount() and check the time between the ACTION_POINTER_DOWN and ACTION_POINTER_UP. You will probably also think about the case where the two touches actually do not come at the exact same time or leave the screen at the exact same time either.

Upvotes: 3

wseme
wseme

Reputation: 835

Not sure what you mean by 2 fingers tap. If you mean a double tap (one finger, 2 taps) , I recommend this:

http://mobile.tutsplus.com/tutorials/android/android-gesture/

But if you are referring to 2 different fingers tapping once, would not recommend doing that a 2 finger tap because it goes against the Android design guidelines. If anything it is recommended to do a long press, which can easily be implemented overriding the onLongClick() method.

But if you really do not want to listen to me because you think I am stupid. You would essentially need to implement your own multi touch gesture. Here is one example:

http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-2-building-the-touch-example/1763

FYI, please be aware of what android version you want to support.

Upvotes: -2

Related Questions