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

After the layout is complete, open ContactListActivity.java. Add code to make the navigation buttons work. Be sure to disable the List button (see “Code the Page’s Behavior” in Chapter 5). Next, change the class declaration line of code so that it extends ListActivity rather than Activity, as shown next:

public class ContactListActivity extends ListActivity {

You will have to import ListActivity. Next, enter the code in Listing 6.3 in the onCreate method after the calls to the button initialization methods.

Listing 6.3 Simple List Activation Code

ContactDataSource ds = new ContactDataSource(this);ds.open();ArrayList<String> names = ds.getContactName();ds.close();

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