Android多点触摸取得Action和对应的PointerIndex
2011-12-22 10:58
183 查看
public static int[] GetTouchActionAndPointerIndex(MotionEvent event) { int action = event.getAction(); int ptrIndex = 0; if (event.getPointerCount() > 1) { int ptrId = (action & MotionEvent.ACTION_POINTER_ID_MASK) >>> MotionEvent.ACTION_POINTER_ID_SHIFT; action = action & MotionEvent.ACTION_MASK; if (action < 7 && action > 4) { action = action - 5; } ptrIndex = event.findPointerIndex(ptrId); } return new int[] { action, ptrIndex }; }其实基本上是抄自《精通Android 2》。只是为了方便编程时不用去翻书。
相关文章推荐
- Android 处理图片放大缩小时报错java.lang.IllegalArgumentException: pointerIndex out of range pointerIndex=-1 ...
- Action取得变量值以后再进行国际化,使有限个不同结果对应不同语言。
- android MotionEvent getAction,getActionMasked,getActionIndex区别
- Android 中 java.lang.IllegalArgumentException: pointerIndex out of range 异常的处理方法
- android中检查action对应的intent是否存在
- Android 中 java.lang.IllegalArgumentException: pointerIndex out of range 异常的处理方法
- Android的OnTouch事件,添加触摸颜色变化,ACTION_UP事件不触发解决方案
- android ICS 4.0.3 报 java.lang.IllegalArgumentException: pointerIndex out of range 解决方案
- Android 多点触控错误处理(java.lang.IllegalArgumentException: pointerIndex out of range)
- 学习Android广播之动作intent.getAction与对应的字符串常量(找不到动作常量时可用)
- Android java.lang.IllegalArgumentException: pointerIndex out of range
- android.database.CursorIndexOutOfBoundsException:Index -1 requested, with a size of 1
- Android ActionBar完全解析,使用官方推荐的最佳导航栏(下)
- Android开发中遇到Java.lang.NullPointerException解决办法
- Android各个版本对应的源代码
- Android:Back button 和 Action Bar UP button 不完全解析
- Android CollapsingToolbarLayout:将ActionBar载入Toolbar(2)
- android 多点触摸应用
- 理论上 Android可以处理 多个手指的触摸
- Android中滑屏实现----手把手教你如何实现触摸滑屏以及Scroller类详解