Create the Custom Adapter

A custom list item is of little use without a custom adapter. Custom adapters are always created as subclasses of another type of adapter that is the closest fit for the behavior needed. Create a new class called ContactAdapter in the com.example.mycontactlist source folder. Modify the class by adding the code in Listing 6.7.

Listing 6.7 ContactAdapter Code

                                                                                  //1public class ContactAdapter extends ArrayAdapter<Contact> {                                                                                  //2    private ArrayList<Contact> items;    private Context adapterContext;                                                                                  //3 ...

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.