2

As the title states. The fact that I can't consume the event is causing a click event to occur immediately afterwards. 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(). What are my options?

4

1 回答 1

0

我认为onLongPress不喜欢onDown这些,onLongPress的返回值不是用来检查什么的,但是onDown的返回值对系统是有用的,它会帮助系统识别另一个事件。从安卓源代码:

   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);

onLongPress 和 ShowPress 只是告诉这些情况发生了。返回值对系统没有用。

如果你想实现你的设计,你可以使用这个变量来检查 LongPress 是否发生。希望这可以帮到你。

于 2012-04-20T05:36:49.323 回答