You'll have to intercept the clicks yourself if you don't want the default Android behaviourbehavior.
You can monitor events in a WebViewWebView
using a WebViewClientWebViewClient
. The method you want is shouldOverrideUrlLoading()shouldOverrideUrlLoading()
. This allows you to perform your own action when a particular URL is selected.
You set the WebViewClientWebViewClient
of your WebViewWebView
using the setWebViewClient(setWebViewClient(
) method.
If you look at the WebView sample in the SDK there's an example which does just what you want. It's as simple as:
private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}