Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Webview disable all links but enable scroll

I am using Webview in android where i load a webpage but, I want all the links to be disabled and web view should be scrollable.

I am using the following code right now:

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

This makes web view disabled but scrolling also goes away.

I have also tried :

tnc.setClickable(false);

but this also doe not work. Please help me out.

like image 579
Sanober Malik Avatar asked Feb 26 '13 11:02

Sanober Malik


1 Answers

If you want to override the clicking of links in the WebView, you can use the shouldOverrideUrlLoading method of the WebViewClient.

webView.setWebViewClient(new WebViewClient(){
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
    }
});
like image 64
Rajesh Avatar answered Nov 19 '22 21:11

Rajesh