Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of a pointer index and in which ways can it be changed?

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

like image 930
Hải Phong Avatar asked Jun 18 '13 10:06

Hải Phong


1 Answers

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

like image 199
thiagolr Avatar answered Oct 21 '22 22:10

thiagolr