Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable text selection in a webview in Android?

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.

like image 281
Dale Avatar asked Jan 09 '12 10:01

Dale


People also ask

How do I turn off text selection on a web page?

You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.

How do I turn off Long press in WebView?

1) android:longClickable="false" 2) webView. setLongClickable(false); 3) webView. setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } });

How do I disable WebView in react native?

In order to enable and disable javascript code in react native application, we need to use below props in WebView component : If we set javaScriptEnabled={true} then it will Enable the JavaScript on WebView. If we set javaScriptEnabled={false} then it will Disable the JavaScript on WebView.


1 Answers

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.

like image 60
Hiren Patel Avatar answered Oct 12 '22 00:10

Hiren Patel