Progress bars are used to show progress of a task. For example, when you are uploading or downloading something from the internet, it is better to show the progress of download/upload to the user.
In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is.
ProgressDialog progress = new ProgressDialog(this);
Now you can set some properties of this dialog. Such as, its style, its text etc.
progress.setMessage("Downloading Music :) "); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setIndeterminate(true);
Apart from these methods, there are other methods that are provided by the ProgressDialog class
Sr. No Title & description
1
getMax()
This method returns the maximum value of the progress.
2
incrementProgressBy(int diff)
This method increments the progress bar by the difference of value passed as a parameter.
3
setIndeterminate(boolean indeterminate)
This method sets the progress indicator as determinate or indeterminate.
4
setMax(int max)
This method sets the maximum value of the progress dialog.
5
setProgress(int value)
This method is used to update the progress dialog with some specific value.
6
show(Context context, CharSequence title, CharSequence message)
This is a static method, used to display progress dialog.
Comments
Post a Comment