Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-在webview上检测手势_Android_Webview - Fatal编程技术网

Android-在webview上检测手势

Android-在webview上检测手势,android,webview,Android,Webview,我正在尝试检测webview上的滑动手势 我尝试使用以下功能: public boolean onTouchEvent(MotionEvent event) { int action = MotionEventCompat.getActionMasked(event); String DEBUG_TAG = "test"; switch (action) { case (MotionEvent.ACTION_DOWN): Log

我正在尝试检测webview上的滑动手势

我尝试使用以下功能:

public boolean onTouchEvent(MotionEvent event) {

    int action = MotionEventCompat.getActionMasked(event);
    String DEBUG_TAG = "test";

    switch (action) {
        case (MotionEvent.ACTION_DOWN):
            Log.d(DEBUG_TAG, "Action was DOWN");
            return true;
        case (MotionEvent.ACTION_MOVE):
            Log.d(DEBUG_TAG, "Action was MOVE");
            return true;
        case (MotionEvent.ACTION_UP):
            Log.d(DEBUG_TAG, "Action was UP");
            return true;
        case (MotionEvent.ACTION_CANCEL):
            Log.d(DEBUG_TAG, "Action was CANCEL");
            return true;
        case (MotionEvent.ACTION_OUTSIDE):
            Log.d(DEBUG_TAG, "Movement occurred outside bounds " +
                    "of current screen element");
            return true;
        default:
            return super.onTouchEvent(event);
    }
}
当没有webview时,它会工作并返回正确答案。 但是,当我添加上述内容时,它在webview上不起作用。由于webview必须是全屏的,我想我不能使用上面的功能。
是否有其他方法或我有问题?

谁是您实施的触摸事件的侦听器?我是否需要实施侦听器?我只是将函数放在活动中而已。尝试实现一个侦听器,并将其传递给webview中的setOnTouchListener函数