您的位置:首页 > 移动开发 > Android开发

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》。只是为了方便编程时不用去翻书。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐