The MotionEvent class has ACTION_DOWN for the first and ACTION_POINTER_DOWN for any subsequent presses, same withh ACTION_UP. Evidently, there isn't an equivalent for ACTION_MOVE from what I've seen. I want to be able to move multiple drawables with the dra开发者_运维技巧g simultaneously. As is, it works fine for multiple presses (just invalidate() for and redraw at the current y location) but will only drag one drawable at a time. I tried making a for loop to go through every pointer, but no dice. Any suggestions?
if(touchnX >= f.getLeft() &&
touchnX <= f.getRight() &&
touchnY <= f.getBottom() &&
touchnY >=f.getTop()){
f.moveThumb(touchnY);
break;
}
That's basically it for the code. I just need to know how to catch subsequent drags.
Can you show the for loop through every pointer? What worked for me is:
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
int numPointers = event.getPointerCount();
for (int i = 0; i < numPointers; i++) {
handleMoveEvent(event.getX(i), event.getY(i));
}
}
However, this will handle move events for all pointers, even if only one moved. I'm not quite sure how to get around that.
精彩评论