Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: how to disable action mode when a user long click on a web view?

How can I disable the action mode. In another word, I want to prevent the action mode from appearing when the user long clicks on a web view that contains a text.

like image 997
Khalid ElSayed Avatar asked Dec 11 '22 19:12

Khalid ElSayed


1 Answers

I haven't worked a lot with WebViews in general, but I think one of these should work. I haven't tested any of these though.

1:

Set the attribute on the WebView in the XML: android:longClickable="false"

Or 2:

Set the above attribute in Java instead of XML:

your_webview.setLongClickable(false);

Or 3: Override your WebView and return true in the setOnLongClickListener method

your_webview.setOnLongClickListener(new OnLongClickListener() {
    @Override
    public boolean onLongClick(View v) {
        return true;
    }
});
like image 168
Siddharth Lele Avatar answered Dec 21 '22 09:12

Siddharth Lele