Like I asked in the title, I don't understand the onTouch() methods behavior when it comes to multi-touch. So I thought that it can be an example of concurrent programming. If it is not can you tell me how does the multi-touch work with onTouch() method?
问问题
98 次
1 回答
1
Concurrent programming means that several thread access to the same class method, this is the case of a servlet for example. The onTouch methods isn't an example of concurrent programming because this method isn't called by different thread. You can detect how many fingers touch the screen using Android API, essentially each finger has and id and you can retrieve the x,y position and the finger id. In onTouch method you have the MotionEvent and you can get the type of action the user is doing:
int action = event.getAction() & MotionEvent.ACTION_MASK;
and to get the finger id:
int idx = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
于 2013-05-09T09:49:58.550 回答