Links sometimes not working in WebView

前端 未结 2 1855
青春惊慌失措
青春惊慌失措 2021-01-26 15:52

On occasion links in the WebView will not respond. The highlight press color will appear around them but nothing happens. I am also using WebViewClient\'s shouldOverrideUrlLoa

相关标签:
2条回答
  • 2021-01-26 16:13

    This seems like a ridiculous work around but I guess it works. The first time the WebView loads, if you load a blank dummy html file like

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    </head>
    <body>
    </body>
    </html>
    

    before you load anything else, it appears to fix the problem. It also looks like the dummy file has to load completely first, not just start loading.

    0 讨论(0)
  • 2021-01-26 16:33

    Just a follow up on this problem : The op solution did not work for me. But I had setLongClickable set to false on the WebView and it completely stopped the WebView to respond to touch events but only on Android 2.1.

    Removing the line :

    webview.setlongclickable(false); 
    

    made the WebView responsive and working as expected again.

    0 讨论(0)
提交回复
热议问题