Android WebView touch event link
Solution 1
You can monitor events in a WebView
using a WebViewClient
. The method you want is shouldOverrideUrlLoading()
. This allows you to perform your own action when a particular URL is selected.
You set the WebViewClient
of your WebView
using the setWebViewClient()
method.
Solution 2
shouldOverrideUrlLoading
good method, but if you click on current
link webview
client not calling to shouldOverrideUrlLoading
method.
wouter88
Updated on June 21, 2022Comments
-
wouter88 almost 2 years
I have a webview with a banner and when I click on the banner there should open a second webview that follows the link. How can I do that? I have created the first WebView and it shows my banner but when I click on it, it opens the link in the same WebView.
How can I catch any events in the WebView when I click on a link that it should do something (with that link)? Just like
shouldStartLoadWithRequest
in iPhone.Thank you,
Wouter
-
Datta Kunde almost 13 yearshow to use shouldOverrideUrlLoading() ? please give short sample code.
-
Datta Kunde almost 13 yearsGot the solution... It write like this "private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { System.out.println("DDD URL: "+url.toString()); view.loadUrl(url); return true; } }"