如何在android中识别三指点击
我想在android屏幕上检测三指点击。我最多能够检测两根手指。如何检测三根手指呢?我听说有些地方说android能够检测两根手指。是这样吗?
I want to detect three finger tap in android screen.I am able to detect up to two fingers.How to detect three fingers it?I heard some where that android is capable of detecting 2 fingers.Is it so?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这段代码可以帮助你:
This code will can help you:
我被要求只处理三个手指的点击。
使用上述解决方案,如果您点击 4 & 5 个手指 以及更多,您将在 onTouchEvent 内触发 3 个手指,因此我必须实现自己的解决方案,因为它很好,所以我可以分享它。
因此,我们的想法是创建一个 CountDownTimer,每当用户完成点击屏幕时就会触发一个事件。
在此示例中,我将 numberOfFingers 定义为 3,因此当且仅当三个手指在屏幕上点击时,我才会显示 Toast。
您可以更改它并获得您想要跟踪的任意数量的手指
首先,创建一个新的 java 类并将其命名为 FingerTapHandler
并且我们还需要一个接口来处理点击事件:OnTouchTimerListener 现在,您可以从上面
的类创建一个新实例,并让您的 Activity 跟踪所需的点击次数。
I was asked to handle only three fingers tap.
With the above solution if you tap 4 & 5 fingers and more you will get 3 fingers triggering inside onTouchEvent so I had to implement my own solution and since it is good I can share it.
so the idea is to create a CountDownTimer that will fire back an event whenever users finish tapping on the screen.
In this example, I defined numberOfFingers to 3 so I show a Toast if and only if three fingers were tapped on the screen.
You can change it and get whatever number of fingers you wish to track
First, create a new java class and name it FingerTapHandler
And also we need an interface to handle the tap event: OnTouchTimerListener
Now, you can create a new instance from the above class and let your Activity tracks the wanted numbers of taps.