[英]Why does onLongPress() not return a boolean like all other SimpleOnGestureListener?
As the title states. 如标题所述。 The fact that I can't consume the event is causing a
click
event to occur immediately afterwards. 我无法使用该事件的事实导致
click
事件随后立即发生。 Now I am manually keeping track of whether or not a longpress has occurred when handling a potential click. 现在,我手动跟踪在处理潜在点击时是否发生了长按。
Am I missing something here? 我在这里想念什么吗? I mean, I can't even get around this trying to implement the OnGestureListener interface because it expects a void for
onLongPress()
. 我的意思是,我什至无法解决尝试实现OnGestureListener接口的问题,因为它期望
onLongPress()
无效。 What are my options? 我有什么选择?
I think the onLongPress don't like the onDown these, the return value of the onLongPress is not used to check something, but the return value of onDown is useful to the system, it will help the system to recognitive another events. 我认为onLongPress不喜欢onDown这些,onLongPress的返回值不用于检查某些东西,但是onDown的返回值对系统很有用,它将帮助系统识别其他事件。 From the android source code:
从android源代码:
mStillDown = true;
mInLongPress = false;
if (mIsLongpressEnabled) {
mHandler.removeMessages(LONG_PRESS);
mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT + LONGPRESS_TIMEOUT);
}
mHandler.sendEmptyMessageAtTime(SHOW_PRESS, mCurrentDownEvent.getDownTime() + TAP_TIMEOUT);
handled |= mListener.onDown(ev);
the onLongPress and ShowPress just tell these situations happend. onLongPress和ShowPress只是告诉您发生了这些情况。 The return value is not useful for system.
返回值对系统没有用。
And if you want to implement your design, you can use the varable to check whether the LongPress happened. 如果要实现设计,则可以使用该变量检查LongPress是否发生。 Hope this can help you.
希望这可以帮到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.