开发者

allow text selection on long press touch event in WebView

开发者 https://www.devze.com 2023-02-23 19:07 出处:网络
I am really new at Java. I have been trying to allow text selection in a WebView on a long press or long touch event. I have it working like this, but it is interfering with the zoom functions of the

I am really new at Java. I have been trying to allow text selection in a WebView on a long press or long touch event. I have it working like this, but it is interfering with the zoom functions of the WebView.

Does anyone know how to change MotionEvent to a long press motion event or anything similar? Keep in mind I am completely new :)

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;
}


Have you looked into using onLongClick instead? See View.setOnLongClickListener

Hope this helps,

Phil Lello


You can use the registerForContextMenu() for detecting longpress..

0

精彩评论

暂无评论...
验证码 换一张
取 消