O'Reilly logo

Android User Interface Development by Jason Morris

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

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... ...

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