capture navigation events from WebView
I have a webview that has some custom HTML loaded into it. In this HTML there is a link to an image. Right now when the user clic开发者_如何学Cks the link, it automatically opens the image in the default android browser. I would instead like to capture that click event and open the URL in my own view as to preserve branding within the UI.
In iOS this is done by using a UIWebViewDelegate, is there something similar for android's WebView?
Create a subclass of WebViewClient
and override shouldOverrideUrlLoading()
. Then, attach an instance of that class to your WebView
via setWebViewClient()
. This works for simple hyperlinks and server-issued redirects.
精彩评论