android.widget
public
interface
android.widget.Adapter
An Adapter object acts as a bridge between an AdapterView and the
underlying data for that view. The Adapter provides access to the data items.
The Adapter is also responsible for making a View for
each item in the data set.
Known Indirect Subclasses
ActivityAdapter,
ActivityIconAdapter,
ArrayAdapter,
BaseAdapter,
CursorAdapter,
GalleryAdapter,
HeaderViewListAdapter,
ListAdapter,
ResourceCursorAdapter,
SimpleAdapter,
SimpleCursorAdapter,
SpinnerAdapter
| ActivityAdapter |
Adapter which shows the set of activities that can be
performed for a given intent. |
| ActivityIconAdapter |
Adapter which shows the set of activities that can be
performed for a given intent. |
| ArrayAdapter |
A ListAdapter that manages a ListView backed by an array of arbitrary
objects. |
| BaseAdapter |
|
| CursorAdapter |
Adapter that exposes data from a Cursor to a
ListView widget. |
| GalleryAdapter |
The GalleryAdapter class acts as a bridge between a Gallery and the
data that backs it. |
| HeaderViewListAdapter |
ListAdapter used when a ListView has header views. |
| ListAdapter |
The ListAdapter class acts as a bridge between a ListView and the data that
backs the list. |
| ResourceCursorAdapter |
An easy adapter that creates views defined in an XML file. |
| SimpleAdapter |
An easy adapter to map static data to views defined in an XML file. |
| SimpleCursorAdapter |
An easy adapter to map columns from a cursor to TextViews or ImageViews
defined in an XML file. |
| SpinnerAdapter |
A SpinnerAdapter acts as a bridge between a
Spinner and the data. |
Summary
Details
Constants
public
static
final
int
NO_SELECTION
Constant Value:
-2147483648
(0x80000000)
Public Methods
public
int
getCount()
How many items are in the data set represented by this Adapter.
public
Object
getItem(int position)
Get the data item associated with the specified position in the data set.
Parameters
| position
| Position of the item whose data we want within the adapter's
data set. |
Returns
- The data at the specified position.
public
long
getItemId(int position)
Get the row id associated with the specified position in the list.
Parameters
| position
| The position of the item within the adapter's data set whose row id we want. |
Returns
- The id of the item at the specified position.
public
int
getNewSelectionForKey(int currentSelection, int keyCode, KeyEvent event)
Given a keyboard key, let the adapter suggest the position in the data
set to be made the new selected item. Return NO_SELECTION to indicate no
appropriate key (for example, the user pressed the back button, or a
subclass does not support this feature).
Parameters
| currentSelection
| the position of the currently selected item. Note that
the index can be less than zero or greater than the number of items in
the data underlying this Adapter, indicating the selection is on a header
or footer item. |
| keyCode
| the keyCode for the event |
| event
| the full key event structure |
Returns
- The position in the data set to be made the new selected item if
a match was found, or NO_SELECTION if there was not a match
public
View
getView(int position, View convertView, ViewGroup parent)
Get a View that displays the data at the specified position in the data
set. You can either create a View manually or inflate it from an XML
layout file. When the View is inflated, the parent View (GridView,
ListView...) will apply default layout parameters unless you use
inflate(int, android.view.ViewGroup, boolean, java.util.Map)
to specify a root view and to prevent attachment to the root.
Parameters
| position
| The position of the item within the adapter's data set of
the item whose view we want. |
| convertView
| The old view to reuse, if possible. Note: You should
check that this view is non-null and of an appropriate type before
using. If it is not possible to convert this view to display the
correct data, this method can create a new view. |
| parent
| The parent that this view will eventually be attached to |
Returns
- A View corresponding to the data at the specified position.
public
void
registerDataSetObserver(DataSetObserver observer)
Register an observer that is called when changes happen to the data used by this adapter.
Parameters
| observer
| the object that gets notified when the data set changes.
|
public
boolean
stableIds()
Indicated whether the item ids are stable across changes to the
underlying data.
Returns
- True if the same id always refers to the same object.