In many cases you won't have to create your own Adapter from scratch. Android supplies a set of Adapters that pump data into native UI controls.
Because Adapters are responsible both for supplying the data and for creating the Views that represent each item, Adapters can radically modify the appearance and functionality of the controls they're bound to.
The following list highlights two of the most useful and versatile native Adapters:
> ArrayAdapter The Array Adapter uses generics to bind an Adapter View to an array of objects of the specified class. By default the Array Adapter uses the toString value of each object in the array to create and populate Text Views. Alternative constructors enable you to use more complex layouts, or you can extend the class to use alternatives to Text Views as shown in the next section.
> SimpleCursorAdapter The Simple Cursor Adapter attaches Views specified within a layout to the columns of Cursors returned from Content Provider queries. You specify an XML layout definition, and then bind each column to a View within that layout. The adapter will create a new View for each Cursor entry and inflate the layout into it, populating each View within the layout using the Cursor column values.
The following sections will delve into these Adapter classes in more detail. The examples provided bind data to List Views, though the same logic will work just as well for other Adapter View classes such as Spinners and Galleries.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.