6

I know a pointer index can be retrieved in this way

int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;

and it is used as a parameter in some methods like event.getPointerId(int pointerIndex) or event.getX(int pointerIndex)

But I don't understand what is the meaning of it, and how it changes its value from one event to the next

Hải Phong
  • 5,094
  • 6
  • 31
  • 49

1 Answers1

6

The pointer index only indicates the data’s position within the MotionEvent. Each pointer also has an ID mapping that stays persistent across touch events. You can retrieve this ID for each pointer using MotionEvent.getPointerId(index) and find an index for a pointer ID using MotionEvent.findPointerIndex(id).

This is usually used for multi touch events!

Good tutorial about multi touch:

http://android-developers.blogspot.com.br/2010/06/making-sense-of-multitouch.html

thiagolr
  • 6,909
  • 6
  • 44
  • 64