我只能find将GestureDetector添加到活动中,并向其添加一个OnDoubleTapListener.但只有在我点击屏幕的背景/布局时才会触发.当我(双击)按钮时不会触发它.
这是我在onCreate中的代码:
gd = new GestureDetector(this, this);
gd.setOnDoubleTapListener(new OnDoubleTapListener()
{
@Override
public boolean onDoubleTap(MotionEvent e)
{
Log.d("OnDoubleTapListener", "onDoubleTap");
return false;
}
@Override
public boolean onDoubleTapEvent(MotionEvent e)
{
Log.d("OnDoubleTapListener", "onDoubleTapEvent");
//if the second tap hadn't been released and it's being moved
if(e.getAction() == MotionEvent.ACTION_MOVE)
{
}
else if(e.getAction() == MotionEvent.ACTION_UP)//user released the screen
{
}
return false;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e)
{
Log.d("OnDoubleTapListener", "onSingleTapConfirmed");
return false;
}
});
本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/ruhezaiandroidzhongdeshitushangtingdoubletap.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 20, 2019 at 07:55 上午