Android ProgressBar Example

We can display the android progress bar dialog box to display the status of work being done e.g. downloading file, analyzing status of work etc.
In this example, we are displaying the progress dialog for dummy file download operation.
Here we are using android.app.ProgressDialog class to show the progress bar. Android ProgressDialog is the subclass of AlertDialog class.
The ProgressDialog class provides methods to work on progress bar like setProgress(), setMessage(), setProgressStyle(), setMax(), show() etc. The progress range of Progress Dialog is 0 to 10000.
Let's see a simple example to display progress bar in android.


  1. ProgressDialog progressBar = new ProgressDialog(this);  
  2. progressBar.setCancelable(true);//you can cancel it by pressing back button  
  3. progressBar.setMessage("File downloading ...");  
  4. progressBar.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);  
  5. progressBar.setProgress(0);//initially progress is 0  
  6. progressBar.setMax(100);//sets the maximum value 100  
  7. progressBar.show();//displays the progress bar  

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

How to extract filename from Uri?

Now, we can extract filename with and without extension :) You will convert your bitmap to uri and get the real path of your file. Now w...