Create a class that implements webviewclient, and add the following code that allows ovveriding the url string, as shown below. You can see these example
public class myWebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }
On your constructor, create a webview object as shown below.
web = new WebView(this); web.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
Then add the following code to load the URLs inside your application.
WebSettings settings=web.getSettings(); settings.setJavaScriptEnabled(true); web.loadUrl("http://www.facebook.com"); web.setWebViewClient(new myWebClient()); web.setWebChromeClient(new WebChromeClient() {
Download demo
Daniel Nyamasyo Jul 15 '16 at 9:11 2016-07-15 09:11
source share