Time for action - building the fruit menu

For the Four Buckets 'o Fruit menu, we're going to need a ListAdapter implementation to render the FruitItem objects into the fruit_item.xml layout resources. We'll also need a layout resource for the GridView which we will load in our new Activity class.

  1. Create a new class named FruitAdapter extending BaseAdapter in the root package of the project.
  2. FruitAdapter needs to hold and represent an array of FruitItem objects. Implement the class using the same structure as the BurgerAdapter.
  3. In the ListAdapter.getView method, set the label and icon as defined in the fruit_item.xml layout resource:
    FruitItem item = items[index]; TextView text = ((TextView)view.findViewById(R.id.text)); ImageView image = ((ImageView)view.findViewById(R.id.icon)); ...

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.