小编Ale*_*lex的帖子

如何使用本机应用在Google Glass上捕获onSwipeDown事件?

我能够使用原生应用中的SimpleOnGestureListener捕获谷歌眼镜触摸板触发的大部分事件.

使用以下代码,您可以捕获这些事件

MainActivity.java:

private GestureDetector gestureDetector;

@Override
protected void onCreate(Bundle savedInstanceState)
{
    gestureDetector = new GestureDetector(this, new MyGestureListener());
}

@Override
public boolean onGenericMotionEvent(MotionEvent event)
{
    gestureDetector.onTouchEvent(event);
    return true;
}
Run Code Online (Sandbox Code Playgroud)

MyGestureListener:

public class MyGestureListener extends android.view.GestureDetector.SimpleOnGestureListener
{
    @Override
    public boolean onFling(MotionEvent start, MotionEvent finish, float velocityX, float velocityY)
    {     
        // check for velocity direction to identify swipe forward / backward / up and down
        return true;
    } 
}
Run Code Online (Sandbox Code Playgroud)

我找到了两个不同的手势处理源:

  1. 在Android中捕获Glass D-Pad事件
  2. 捕获手势控件以在原生Android玻璃应用中使用

但是没有一个我能够捕获swipeDown事件.

回调onFling()仅在"向前滑动","向后滑动"和"向上滑动"时调用,但在"向下滑动"时从不调用.

任何提示或你已经设法抓住了向下滑动?我在这里真的很无能为力.

android android-gesture google-glass

10
推荐指数
1
解决办法
1993
查看次数

标签 统计

android ×1

android-gesture ×1

google-glass ×1