How to disable text selection in a webview in Android?
Asked Answered
U

1

6

My application playing HTML promotions in WebView, Html promotions having text so if user press long click android standard dialog appear Copy/Share/Find/Web Search, so is there any option to disable text selection dialog for webview ?

Help me on the same.

Urbanus answered 9/1, 2012 at 10:56 Comment(1)
#5108151 The first aswer with javascript works perfect.Urbanus
M
16

You need to do this way:

WebView webView = (WebView) findViewById(R.id.webView);

webView.setOnLongClickListener(new View.OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
          return true;
      }
    });
webView.setLongClickable(false);

// Below line prevent vibration on Long click
webView.setHapticFeedbackEnabled(false);

Hope this will help you.

Minnow answered 4/4, 2016 at 7:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.