Time for action - creating an ArrayAdapter

The ListItemSelectionActivity class will accept list content from two different sources. You can either specify a database query Uri that will be used to select two columns from an external source, or you can specify an Object array as extra data in the Intent object. For the next task, we'll write a private utility method to create an ArrayAdapter from the Intent object.

  1. Open the ListItemSelectionActivity Java source file in your editor or IDE.
  2. Declare a new utility method to create a ListAdapter for Intent:
    private ListAdapter createArrayAdapter(Intent intent) {
    
  3. Fetch an Object array from the extra data in Intent:
    Object[] data = (Object[])intent.getSerializableExtra("data");
    
  4. If the array is not null

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.