在onTouchEvent(MotionEvent event)方法里面获取多个指头的index和actionCode,以此来判断是哪个手指头做了动作。 //获得手指的数量 int count=event.getPointerCount(); int action=event.getAction(); int index=(action&MotionEvent.ACTION_POINTER_INDEX_MASK)>>MotionEvent.ACTION_POINTER_INDEX_SHIFT; //获取指针索引 int actionCode=action&MotionEvent.ACTION_MASK;//获取动作编码
//获得手指的数量
int count=event.getPointerCount();
int action=event.getAction();
int index=(action&MotionEvent.ACTION_POINTER_INDEX_MASK)>>MotionEvent.ACTION_POINTER_INDEX_SHIFT; //获取指针索引
int actionCode=action&MotionEvent.ACTION_MASK;//获取动作编码
我不明白怎么用onTouchEvent这个方法
在我一楼的代码之前,我是这样写的:
声明定义了一个GestureDetector detector 然后,
layout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
return detector.onTouchEvent(event);
}
})你是指这里的onTouchEvent吗?
你的意思是要重写一下这个onTouchEvent?