0

我如何获得双击事件触摸的 X 和 Y 位置,可能就像您选择初始位置和最终位置的游戏,所以我得到oldX,oldYnewX,newY

我已经尝试了一个最初的if...else声明并在两者中都修改了这个布尔值,因为我只想获得两次触摸。boolean firsttouchtrueifelse

注意:我不是在说拖动;

4

1 回答 1

1

GestureDetector您需要使用如下方式实现双击事件:

GestureDetector gd = new GestureDetector(this);
  gd.setOnDoubleTapListener(new OnDoubleTapListener()
    {
        public boolean onSingleTapConfirmed(MotionEvent e)
        {
            Toast.makeText(getApplicationContext(),"Single Tap Called", Toast.LENGTH_SHORT).show();
            return false;
        }
        public boolean onDoubleTapEvent(MotionEvent e)
        {
            return false;
        }
        public boolean onDoubleTap(MotionEvent e)
        {
            Toast.makeText(getApplicationContext(), "Double Tap Called", Toast.LENGTH_SHORT).show();
        }
    });
于 2013-01-04T06:33:18.710 回答