Updated 22 September 2017
What is Webview?
Webview: A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more.
We can easily add our loading text and loader by creating a WebChromeClient subclass.
WebChromeClient-
This class is called when something that might impact a browser UI happens, for instance, progress updates and JavaScript alerts.
1 2 3 4 5 6 7 8 9 10 |
class MyChromeBrowser extends WebChromeClient { public void onProgressChanged(WebView view, int progress) { PaymentWebViewActivity.this.setTitle("Loading..."); PaymentWebViewActivity.this.setProgress(progress * 100); if(progress == 100) { PaymentWebViewActivity.this.setTitle(R.string.app_name); } } } |
In this example MyChromeBrowser is a subclass of WebChromeClient, that override the onProgressChanged( ) method and here we can set the title of Activity.
Now add MyChromeBrowser object to our WebView,
1 |
webView.setWebChromeClient(new MyChromeBrowser()); |
-With this method, we can easily add loader for every page loading.
– one more method we can add our progress. see the Link- https://mobikul.com/show-loader-webview-load-url/
Layout looks like –
References: https://developer.android.com/reference/android/webkit/WebView.html
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.