O'Reilly logo

Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android by Michael Eierman, Jakob Iversen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code the Activity

You are almost ready to test your custom adapter. But first you need to change the ContactListActivity code to retrieve contact objects rather than contact names, set the ListView to use the custom adapter, and code the onItemClick method to pass the selected contact’s ID to ContactActivity. The first two changes require changing only one line of code each. Switch to the ContactListActivity.java. Code the activity to retrieve Contact objects rather than names by changing the

ArrayList<String> names = ds.getContactName();

line of code to

final ArrayList<Contact> contacts = ds.getContacts();

The final keyword needs to be added because you will now use the ArrayList inside ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required