Using a List View

On the ReviewList Activity of the RestaurantFinder application, shown in figure 3.2, you can see a different type of View than the simple user inputs and labels we have used up to this point—this screen presents a scrollable list of choices for the user to choose from.

This Activity is using a ListView component to display a list of review data that is obtained from calling the Google Base Atom API using HTTP (we will refer to this as a "web service," even though it is not technically SOAP or any other formal standard). After we make the HTTP call, by appending the user's criteria to the required Google Base URL, we will then parse the results with the Simple API for XML (SAX) and create a List of reviews. The details of XML parsing won't be our focus here—that will come in chapter 11—and neither will the use of the network itself, which is covered in chapter 6, but the views we will build based on the data we get back will be. The resulting List will be used to populate our screen's list of items to choose from.

The code in listing 3.3 shows how we create and use a ListView to represent this list of items to choose from on an Activity screen.

0 0

Post a comment