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

ProgressBar1

public class ProgressBar1 extends android.app.Activity
Demonstrates how to use progress bars as widgets and in the title bar. Demonstrates the use of the two different sizes for progress bars.

Fields Summary
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);

        requestWindowFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.progressbar_1);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
                Window.PROGRESS_VISIBILITY_ON);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 5000);

        final ProgressBar progress = (ProgressBar) findViewById(R.id.progress_big);
        final ProgressBar progressSmall = (ProgressBar) findViewById(R.id.progress_small);

        Button button = (Button) findViewById(R.id.increase);
        button.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                progress.incrementProgressBy(1);
                progressSmall.incrementProgressBy(1);
                // window's progress is in range 0..10000
                getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
                        10000 * progressSmall.getProgress() / 100);
            }
        });

        button = (Button) findViewById(R.id.decrease);
        button.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                progress.incrementProgressBy(-1);
                progressSmall.incrementProgressBy(-1);
                // window's progress is in range 0..10000
                getWindow().setFeatureInt(Window.FEATURE_PROGRESS,
                        10000 * progressSmall.getProgress() / 100);
            }
        });