开发者

How to select text from a webview and not copy it?

开发者 https://www.devze.com 2023-04-12 13:15 出处:网络
I am creating an application which requires a webview. I want to enable text selection in webview. (I found a few solutions but none of them worked)

I am creating an application which requires a webview.

I want to enable text selection in webview. (I found a few solutions but none of them worked)

Once the webview is selected, it should not be directly copied. I should be able to expand the selection range with handles (It is possible in versi开发者_开发技巧on 2.3 and later. But I want this on versions lower than 2.3. HTC's browser gives us this option)

Any idea?


recently i solved that

put this function on create or on load in activity

private void emulateShiftHeld(WebView view)
{
    try
    {
        KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
                                                KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
        shiftPressEvent.dispatch(view);

    }
    catch (Exception e)
    {
        Log.e("dd", "Exception in emulateShiftHeld()", e);
    }
}

it will done...

0

精彩评论

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

关注公众号