For some of the more frequent pages, the client generally use the method of loading H5, this time will be used to webview, in use, not directly throw it a URL address so simple things, but also need some additional configuration.
publicvoidsetWebViewClient(WebViewClient client) { checkThread(); mProvider.setWebViewClient(client);}对于WebView来说,WebViewClient是一个很重要的类,它会接收各种通知和请求,如果WebView设置了WebViewClient,那么它就掌握了控制url的权利,否则,当WebView加载url时,会跳转到浏览器。
Let's take a look at what important methods it provides.
publicbooleanshouldOverrideUrlLoading(WebView view, String url) { returnfalse;}如果返回true,当前的WebView会处理url。返回false,则交给安装的浏览器来处理。记得 一定要返回true啊。
publicvoidonPageStarted(WebView view, String url, Bitmap favicon) {}页面开始加载的时候,这个方法会被调用,一般会在这个方法里显示进度条等。
publicvoidonPageFinished(WebView view, String url) {}页面加载完成以后调用这个方法,在这个方法可以隐藏进度条或者其他操作。
Like Webchromeclient and Webviewclient, Setup will also give WebView the right to control the URL, which provides the main methods:
告诉WebView当前加载进度publicvoidonProgressChangedint newProgress) {}
获取当前页面的标题publicvoidonReceivedTitle(WebView view, String title) {}
现在的H5,几乎都会包含js把,为了支持js,就需要用到下面这个方法了,webview.getSettings().setJavaScriptEnabled(true);
The above is just some of the most basic settings, want to learn more about WebView, you can refer to the following article
Cache:
http://blog.csdn.net/t12x3456/article/details/13745553
http://blog.csdn.net/liufeng520/article/details/49329213
Android and WebView interaction
http://download.csdn.net/detail/wangtingshuai/5106571
WebView Usage Summary