Android Webview disables all links but allows scrolling

I use Webview in android, where I load a webpage, but I want all links to be disabled and the webview should scroll.

I am using the following code right now:

tnc.setOnTouchListener(new View.OnTouchListener() {
                     public boolean onTouch(View v, MotionEvent event) {
                        return true;
                     }
                 });

This disables web browsing, but the scroll also disappears.

I also tried:

tnc.setClickable(false);

but it also does not work. Please help me.

+5
source share
2 answers

If you want to override the click of links in WebView, you can use the shouldOverrideUrlLoadingmethod WebViewClient.

webView.setWebViewClient(new WebViewClient(){
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
    }
});
+18
source

just add this to your webview in layout android:focusableInTouchMode="false"

-1
source

All Articles