Create the Layout

Now that you have a way to get contact data, the next step is to modify the activity_contact_list.xml file to include a ListView widget. Open this file and delete the HelloWorld TextView if you have not already done so (see creating the layout in the “Using Preferences” section of Chapter 5, “Persistent Data in Android”). Also add the navigation bar if you haven’t done that. Be sure to delete the paddingLeft, attributes, and the like in the root RelativeLayout. In Graphical Layout, from the Composite folder in the Palette, drag a ListView to anywhere on the layout. Switch to activity_contact_list.xml and modify the XML for the ListView widget to match Listing 6.2.

Listing 6.2 ListView XML

<ListView ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.