FileDocCategorySizeDatePackage
ProgressBar3.javaAPI DocGoogle Android v1.5 Example3402Sun Nov 11 13:01:04 GMT 2007com.google.android.samples.view

ProgressBar3

public class ProgressBar3 extends android.app.Activity
Demonstrates the use of progress dialogs.

Fields Summary
private android.app.ProgressDialog
mDialog
private int
mProgress
private boolean
mCancelled
private android.os.Handler
mHandler
private static final int
PROGRESS
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        setContentView(R.layout.progressbar_3);

        Button button = (Button) findViewById(R.id.showProgress);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                mCancelled = false;
                mProgress = 0;
                OnCancelListener cancelListener = new OnCancelListener() {
                    public void onCancel(DialogInterface dialog) {
                        mCancelled = true;
                        //todo: remove before submiting
//                        Log.v("ProgressBarTest", "Canceled the progress bar.");
                    }
                };

                mDialog = ProgressDialog.show(ProgressBar3.this,
                        "Doing Stuff", "Please wait while loading...", false,
                        true, cancelListener);

                mHandler.sendMessage(mHandler.obtainMessage(PROGRESS));
            }
        });

        button = (Button) findViewById(R.id.showIndeterminate);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ProgressDialog.show(ProgressBar3.this,
                        "Indeterminate", "Please wait while loading...", true,
                        true);
            }
        });

        button = (Button) findViewById(R.id.showIndeterminateNoTitle);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                ProgressDialog.show(ProgressBar3.this,
                        null, "Please wait while loading...", true, true);
            }
        });