written by: hardiks•edited by: Simon Hill•updated: 5/3/2011
This tutorial will explain how to add a progress dialog or progress bar to your application using the Google Android programming environment.
slide 1 of 1
In this tutorial, I will show you how to add a progress dialog to your Android application. A dialog is usually a small window or tab that appears before any activity in your application. It is intended to display alerts or information to the user. A progress dialog can be used to either show some processing activity to the user or to show the progress of some custom activity using the progress bar. It can be used in many situations, like to display the size of the files being downloaded and to show the amount of time left to finish a certain activity etc.
To create a Progress Dialog, we can make use of the ProgressDialog class which is an extension of the AlertDialog class. It can be used to display a standard progress dialog with a spinning wheel and some custom text. You can display your Progress Dialog using a simple show () call on your dialog object.
Here's the syntax to create a standard Progress dialog:
Also enter the dialog message text to whatever you want and whether it is cancelable or not.
Now, if you want to increment or edit the progress displayed on the progress bar from your application, just call incrementProgressBy(int) or setProgress(int) on pbarDialog with an appropriate int value.
Here is how the progress bar or progress dialogs will actually look like in your application.