Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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_Motion Detection - Fatal编程技术网

Android 允许在WebView中的长按触摸事件上选择文本

Android 允许在WebView中的长按触摸事件上选择文本,android,webview,motion-detection,Android,Webview,Motion Detection,我对Java真的很陌生。我一直在尝试允许在长按或长触事件的网络视图中选择文本。我让它像这样工作,但它干扰了WebView的缩放功能 有人知道如何将MotionEvent更改为长按动作事件或类似的事件吗? 请记住,我是全新的:) 你有没有考虑改用它?请参阅View.setOnLongClickListener 希望这有帮助 Phil Lello您可以使用registerForContextMenu()来检测longpress public boolean onTouchEvent(MotionEv

我对Java真的很陌生。我一直在尝试允许在长按或长触事件的网络视图中选择文本。我让它像这样工作,但它干扰了WebView的缩放功能

有人知道如何将MotionEvent更改为长按动作事件或类似的事件吗? 请记住,我是全新的:)


你有没有考虑改用它?请参阅View.setOnLongClickListener

希望这有帮助


Phil Lello

您可以使用registerForContextMenu()来检测longpress

public boolean onTouchEvent(MotionEvent "ACTION_DOWN") {
    try {
        KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
                KeyEvent.KEYCODE_SHIFT_LEFT,0,0);
        shiftPressEvent.dispatch(webview);
    } catch (Exception e) {
        throw new AssertionError(e);
    }
    return false;
}