下面是我的问题的场景:Android:多点触控问题
- 我按下了屏幕。我可以使用MotionEvent类的ACTION_DOWN变量跟踪此触摸事件。当我将这个初始手指按在屏幕上时,我的问题就出现了。我希望能够跟踪屏幕上的任何其他触摸事件。
我认为我的问题基本上是,即使在发生触摸事件时,我如何跟踪后续触摸事件?
最佳, Aneem
编辑:
public boolean onTouchEvent(final MotionEvent ev) {
if(ev.getAction()==ev.ACTION_DOWN||ev.getActionMasked()==ev.ACTION_POINTER_DOWN){
AudioManager mgr = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
int streamVolume = mgr.getStreamVolume(AudioManager.STREAM_MUSIC);
PointF[] touchPoints = new PointF[ev.getPointerCount()];
for(int i = 0; i < ev.getPointerCount(); i++){
touchPoints[i] = new PointF(ev.getX(i),ev.getY(i));
}
for(final PointF point : touchPoints){
x = ev.getX(ev.getActionIndex());
y = ev.getY(ev.getActionIndex());
int ptx = (int) (x - x%widthIncrement);
int pty = (int) (y - y%heightIncrement);
playSound(pointMap.get(new Point(ptx,pty)));
}
return true;
}
return true;
}