Categories

Follow Us @web_learners

Monday, April 6, 2020

How to Add Progress Dialog in Android Webview App| Webview App Development Series Part 6

Hi, Today I am going to show you how to add progress dialog in Webview or any android app. Let's Start.


First, you need to take a global ProgressDialog, I called it pd;

Code:



After that within "oncreate" section you need to assign that variable pd, then you have to set Message which you want to show when the website loading. In my case, I will show "Loading Please wait....".

After that, you need to write a function below "onCreate" and then you need to call that function inside onCreate and pass into WebViewClient function. See below code:


Code:



I have given the name of that function is "mbfllixer" and "web" is my variable name, in that variable I stored webview layout. Also you have to call an override function "onPageFinished". When our website loading will finish, the Progress Dialog should go. So, the code will be:

Code:



We have finished the coding for showing Progress Dialog. So the whole final code will be in MainActivity.java is :

Code:



And the whole code will be in activity_main.xml is :


Code:



That's it, now we will run our project, As you can see in my screenshot below we have successfully added Progress Dialog in our Webview App.


If you face any problem, you can let us know in the comment box below. Thanks.

No comments:

Post a Comment