Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android WebView touch event link

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

like image 425
wouter88 Avatar asked Dec 23 '09 08:12

wouter88


2 Answers

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.

like image 113
Dave Webb Avatar answered Nov 15 '22 13:11

Dave Webb


shouldOverrideUrlLoading good method, but if you click on current link webview client not calling to shouldOverrideUrlLoading method.

like image 43
SBotirov Avatar answered Nov 15 '22 14:11

SBotirov