1 / 6

Adapters

Adapters. Adapters (again!). Adapters are bridging classes, that bind data to user-interface Views. The adapter is responsible for creating the child views used to represent each item and providing access to the underlying data.

mabyn
Download Presentation

Adapters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adapters CS440

  2. Adapters (again!) • Adapters are bridging classes,that bind data to user-interface Views. The adapter is responsible for creating the child views used to represent each item and providing access to the underlying data. • User-interface controls that support Adapter binding must extend the AdapterView abstract class. • It’s possible to create your own AdapterView-derived controls and create new Adapter classes to bind them. CS440

  3. Android supplied Adapters • Android supplies a set of Adapters that pump data into the native user-interface widgets. • Because Adapters are responsible both for supplying the data and selecting the Views that represent each item, Adapters can radically modify the appearance and functionality of the controls they’re bound to. CS440

  4. Android supplied Adapters • ArrayAdapter: The ArrayAdapter is a generic class that binds Adapter Views to an array of objects. • By default, the ArrayAdapter binds the toString value of each object to a TextView control defined within a layout. • Alternative constructors allow you to use more complex layouts, or you can extend the class to use alternatives to Text View (such as populating an ImageViewor nested layout) by overriding the getView method. CS440

  5. Android supplied Adapters • SimpleCursorAdapter:The SimpleCursorAdapter binds Views to cursors returned from Content Provider queries. You specify an XML layout definition and then bind the value within each column in the result set, to a View in that layout. CS440

  6. References • Professional Android 2 Application Development (Wrox Programmer to Programmer) by RetoMeier • http://developer.android.com CS440

More Related