Adding a List
Figure 10. Adding a list to the top and sliding the form to the bottom
Step #5: Build and Attach the Adapter...............................................
The ListView will remain empty, of course, until we do something to
populate it. What we want is for the list to show our running lineup of
restaurant objects.
Since we have our ArrayList
ArrayAdapter
restaurant, we need to add it to the ArrayAdapter via add() – the adapter
will, in turn, put it in the ArrayList. Otherwise, if we add it straight to the
ArrayList, the adapter will not know about the added restaurant and
therefore will not display it.
Here is the new implementation of the LunchList class:
package apt.tutorial;
import android.app.Activity;