Starting the Progress Indicator

Next, you need to implement the onPreExecute() method, which runs on the UI thread before background processing begins. This is the perfect place to demonstrate adding to the title bar an indeterminate progress indicator: ©Override protected void onPreExecute() { mProgressCounter++;

QuizScoresActivity.this.setProgressBarlndeterminateVisibility(true);

There are two tabs of scores. Each tab's scores are downloaded separately, and you want the progress indicator to display until both are complete. Thus, you can create a counter, mProgressCounter, to track each download. In this way, you could also add a third tab, and the indicator would still hide at the correct time.

In the onCreate() method of the activity, the following line must be added before the indeterminate progress bar indicator will display properly in the title bar: requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

You must call this method before you call the setContentView() method.

0 0

Post a comment