Showing a progress bar

To show the progression with an animated progress bar:

1. Initialize the ProgressDialog with the class constructor, ProgressDialog(Context).

2. Set the progress style to "STYLE_HORIZONTAL" with setProgressStyle(int) and set any other properties, such as the message.

3. When you're ready to show the dialog, call show() or return the ProgressDialog from the onCreateDialog(int) callback.

4. You can increment the amount of progress displayed in the bar by calling either setProgress(int) with a value for the total percentage completed so far or incrementProgressBy(int) with an incremental value to add to the total percentage completed so far.

For example, your setup might look like this:

ProgressDialog progressDialog;

progressDialog = new ProgressDialog(mContext);

progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

progressDialog.setMessage("Loading...");

progressDialog.setCancelable(false);

0 0

Post a comment