TUTORIAL 8
Sitting in the Background
In this tutorial, we will simulate having the LunchList do some background
processing in a secondary thread, updating the user interface via a progress
bar. While all of these tutorials are somewhat contrived, this one will be
more contrived than most, as there is not much we are really able to do in a
LunchList that would even require long processing in a background thread.
So, please forgive us if this tutorial is a bit goofy.
Step-By-Step Instructions..........................................................................
First, you need to have completed the previous tutorial. If you are
beginning the tutorials here, or if you wish to not use your existing work,
you can download a ZIP file with all of the tutorial results, and you can copy
the 07-MenusMessages edition of LunchList to use as a starting point.
Step #1: Initialize the Progress Bar.....................................................
For this application, rather than use a ProgressBar widget, we will use the
progress bar feature of the Activity window. This will put a progress bar in
the title bar, rather than clutter up our layouts.
This requires a bit of initialization. Specifically, we need to add a line to
onCreate() that will request this feature be activated. We have to do this
before calling setContentView(), so we add it right after chaining to the
superclass: