[英]Android: How to correlate ACTION_DOWN and ACTION_MOVE events that come from the same drag motion
I want to allow the user to drag controls vertically in my OpenGL view (like a scrollbar). 我想允许用户在OpenGL视图中垂直拖动控件(如滚动条)。 To implement this I plan to do the following:
为此,我计划执行以下操作:
onTouchEvent
to listen for motion events onTouchEvent
侦听运动事件 ACTION_DOWN
, record the vertical offset between the touch location and the control ACTION_DOWN
,记录触摸位置和控件之间的垂直偏移 ACTION_MOVE
, inch the control upwards/downwards depending on which way the user drags ACTION_MOVE
,根据用户拖动的方式向上/向下拖动控件 ACTION_UP
, delete the offset ACTION_UP
,删除偏移量 I want to support the user dragging multiple controls at the same time, so I need to be able to get some kind of ID from the ACTION_DOWN
event that I can use as the hashtable entry for the offset. 我想支持用户同时拖动多个控件,因此我需要能够从
ACTION_DOWN
事件中获取某种ID,该ID可用作偏移量的哈希表条目。 Later, when handling ACTION_MOVE
I need to be able to get that same ID to look up the offset in the hashtable, in order to ensure that we don't mix up 2 controls that are being dragged at the same time. 稍后,在处理
ACTION_MOVE
我需要能够获得相同的ID来查找哈希表中的偏移量,以确保我们不会混淆同时拖动的2个控件。 How do I get this 'ID' so I can correlate the ACTION_DOWN
and ACTION_MOVE
events that come from the same drag motion? 如何获得此“ ID”,以便可以关联来自同一拖动动作的
ACTION_DOWN
和ACTION_MOVE
事件?
原来MotionEvent.downTime
是我一直在寻找的属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.