Multi-touch two finger taps

I need to implement two fingers tap.

For example, I have a listView with several elements that already have a click listener for each row and the listener's touch. Now I have to do something if the user put two fingers on the line.

How can i do this?

Any suggestion is appreciated.

+4
source share
3 answers

I believe the gesture API only supports one touch.

Basically, you should override ` onTouchEvent and play with e.getPointerCount () and check the time between ACTION_POINTER_DOWN and ACTION_POINTER_UP. You will probably also think of a case where two touches do not actually appear at the same time or leave the screen at the same time.

+3
source

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

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

But if you refer to 2 different finger presses once, I would not recommend 2 fingers to do this, because this contradicts the recommendations for Android development. If something is recommended, do a long press, which can be easily implemented by overriding the onLongClick () method.

But if you really don't want to listen to me because you think I'm stupid. You, in fact, will 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 keep in mind which version of Android you want to support.

-2
source

Source: https://habr.com/ru/post/1436375/


All Articles