Reputation: 41
I saw several articles here about implementing the WebviewClient so that the transitions in the webview stay in webview rather than go to the browser.
When I try to run my application the webview loads but it still doesn't correct the page transition problem. Is it possible that I need to replace the "shouldoveride" with the "On Create"?
Here is my code:
public class WebViewActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.webview1);
WebSettings webSettings = wv.getSettings();
webSettings.setBuiltInZoomControls(true);
wv.loadUrl("http://www.yahoo.com");
}
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return(true);
}
}
}
Upvotes: 3
Views: 169
Reputation: 4015
Or simply add WebChromeClient()
:
WebView wv = (WebView) findViewById(R.id.webview1);
wv.setWebChromeClient(new WebChromeClient());
Using WebChromeClient
allows you to handle Javascript dialogs!
Upvotes: 0
Reputation: 72653
You didn't assign your WebViewClient
to your WebView. Do this:
wv.setWebViewClient(new Callback());
Upvotes: 1
Reputation: 30874
If you just want to show all pages inside the WebView
instead of openning then in the default browser, you only need to speficy a WebViewClient
. It's not even necessary to create a custom class that extends WebViewClient
wv.setWebViewClient(new WebViewClient());
Upvotes: 1