java.lang.Object | ||
↳ | android.widget.BaseAdapter | |
↳ | android.widget.SimpleAdapter |
An easy adapter to map static data to views defined in an XML file. You can specify the data
backing the list as an ArrayList of Maps. Each entry in the ArrayList corresponds to one row
in the list. The Maps contain the data for each row. You also specify an XML file that
defines the views used to display the row, and a mapping from keys in the Map to specific
views.
Binding data to views occurs in two phases. First, if a
SimpleAdapter.ViewBinder
is available,
setViewValue(android.view.View, Object, String)
is invoked. If the returned value is true, binding has occurred.
If the returned value is false, the following views are then tried in order:
setViewText(TextView, String)
is invoked.
setViewImage(ImageView, int)
or setViewImage(ImageView, String)
is invoked.
IllegalStateException
is thrown.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
SimpleAdapter.ViewBinder | This class can be used by external clients of SimpleAdapter to bind values to views. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.widget.Adapter
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
How many items are in the data set represented by this Adapter.
| |||||||||||
Gets a
View that displays in the drop down popup
the data at the specified position in the data set.
| |||||||||||
Returns the value previously set by a call to
setDropDownViewTheme(Theme) .
| |||||||||||
Returns a filter that can be used to constrain data with a filtering pattern. | |||||||||||
Get the data item associated with the specified position in the data set.
| |||||||||||
Get the row id associated with the specified position in the list.
| |||||||||||
Get a View that displays the data at the specified position in the data set.
| |||||||||||
Returns the
SimpleAdapter.ViewBinder used to bind data to views.
| |||||||||||
Sets the layout resource to create the drop down views. | |||||||||||
Sets the
Resources.Theme against which drop-down views are
inflated.
| |||||||||||
Sets the binder used to bind data to views.
| |||||||||||
Called by bindView() to set the image for an ImageView but only if
there is no existing ViewBinder or if the existing ViewBinder cannot
handle binding to an ImageView.
| |||||||||||
Called by bindView() to set the image for an ImageView but only if
there is no existing ViewBinder or if the existing ViewBinder cannot
handle binding to an ImageView.
| |||||||||||
Called by bindView() to set the text for a TextView but only if
there is no existing ViewBinder or if the existing ViewBinder cannot
handle binding to a TextView.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.BaseAdapter
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
android.widget.ListAdapter
| |||||||||||
From interface
android.widget.SpinnerAdapter
| |||||||||||
From interface
android.widget.Filterable
| |||||||||||
From interface
android.widget.ThemedSpinnerAdapter
| |||||||||||
From interface
android.widget.Adapter
|
Constructor
context | The context where the View associated with this SimpleAdapter is running |
---|---|
data | A List of Maps. Each entry in the List corresponds to one row in the list. The Maps contain the data for each row, and should include all the entries specified in "from" |
resource | Resource identifier of a view layout that defines the views for this list item. The layout file should include at least those named views defined in "to" |
from | A list of column names that will be added to the Map associated with each item. |
to | The views that should display column in the "from" parameter. These should all be TextViews. The first N views in this list are given the values of the first N columns in the from parameter. |
How many items are in the data set represented by this Adapter.
Gets a View
that displays in the drop down popup
the data at the specified position in the data set.
position | index 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 |
View
corresponding to the data at the
specified position.
Returns the value previously set by a call to
setDropDownViewTheme(Theme)
.
Resources.Theme
against which drop-down views are
inflated, or null
if one has not been explicitly set
Returns a filter that can be used to constrain data with a filtering pattern.
This method is usually implemented by Adapter
classes.
Get the data item associated with the specified position in the data set.
position | Position of the item whose data we want within the adapter's data set. |
---|
Get the row id associated with the specified position in the list.
position | The position of the item within the adapter's data set whose row id we want. |
---|
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)
to specify a root view and to prevent attachment to the root.
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.
Heterogeneous lists can specify their number of view types, so that this View is
always of the right type (see getViewTypeCount() and
getItemViewType(int) ). |
parent | The parent that this view will eventually be attached to |
Returns the SimpleAdapter.ViewBinder
used to bind data to views.
Sets the layout resource to create the drop down views.
resource | the layout resource defining the drop down views |
---|
Sets the Resources.Theme
against which drop-down views are
inflated.
By default, drop-down views are inflated against the theme of the
Context
passed to the adapter's constructor.
theme | the theme against which to inflate drop-down views or
null to use the theme from the adapter's context |
---|
Sets the binder used to bind data to views.
viewBinder | the binder used to bind data to views, can be null to remove the existing binder |
---|
Called by bindView() to set the image for an ImageView but only if
there is no existing ViewBinder or if the existing ViewBinder cannot
handle binding to an ImageView.
This method is called instead of setViewImage(ImageView, String)
if the supplied data is an int or Integer.
v | ImageView to receive an image |
---|---|
value | the value retrieved from the data set |
Called by bindView() to set the image for an ImageView but only if
there is no existing ViewBinder or if the existing ViewBinder cannot
handle binding to an ImageView.
By default, the value will be treated as an image resource. If the
value cannot be used as an image resource, the value is used as an
image Uri.
This method is called instead of setViewImage(ImageView, int)
if the supplied data is not an int or Integer.
v | ImageView to receive an image |
---|---|
value | the value retrieved from the data set |
Called by bindView() to set the text for a TextView but only if there is no existing ViewBinder or if the existing ViewBinder cannot handle binding to a TextView.
v | TextView to receive text |
---|---|
text | the text to be set for the TextView |