Time for action - presenting Burger objects

The standard ListAdapter classes work well if your data objects are either strings or easily represented as strings. In order to display our Burger objects nicely on the screen, we need to write a custom ListAdapter class. Fortunately, Android provides us with a nice skeleton class for ListAdapter implementations named BaseAdapter.

  1. Create a new class named BurgerAdapter, and have it extend from the android.widget.BaseAdapter class:
    class BurgerAdapter extends BaseAdapter {
    
  2. An Adapter is part of the presentation layer, but is also the underlying model of the ListView. In the BurgerAdapter we store an array of Burger objects which we assign in the constructor:
    private final Burger[] burgers; BurgerAdapter(Burger... ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.