Android Tutorial

(avery) #1
Android Tutorial 191

<ProgressBar
android:id=”@+id/progress_bar”
style=”?android:attr/progressBarStyleHorizontal”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:max=”100” />


We have also set the attribute for max in this sample to 100.This
can help mimic a percentage progress bar. That is, setting the
progress to 75 shows the indicator at 75 percent complete.

We can set the indicator progress status programmatically as
follows:

mProgress = (ProgressBar) findViewById(R.id.progress_bar);
mProgress.setProgress(75);


You can also put these progress bars in your application’s title bar.
This can save screen real estate. This can also make it easy to turn
on and off an indeterminate progress indicator without changing
the look of the screen. Indeterminate progress indicators are
commonly used to display progress on pages where items need to
be loaded before the page can finish drawing. This is often
employed on web browser screens. The following code
demonstrates how to place this type of indeterminate progress
indicator on your Activity screen:

requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
requestWindowFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.indicators);
setProgressBarIndeterminateVisibility(true);
setProgressBarVisibility(true);
setProgress(5000);


To use the indeterminate indicator on your Activity objects title bar,
you need to request the feature
Free download pdf