# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Nested Classes | Inherited Constants | Ctors | Methods | Inherited Methods

# SimpleAdapter

`public class SimpleAdapter`
`` `extends BaseAdapter` `implements Filterable, ThemedSpinnerAdapter`

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, `ViewBinder#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:

- A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean.
- TextView. The expected bind value is a string and `setViewText(android.widget.TextView, java.lang.String)` is invoked.
- ImageView. The expected bind value is a resource id or a string and `setViewImage(android.widget.ImageView, int)` or `setViewImage(android.widget.ImageView, java.lang.String)` is invoked.

If no appropriate binding can be found, an `IllegalStateException` is thrown.

## Summary

### Nested classes
`interface` | `SimpleAdapter.ViewBinder` This class can be used by external clients of SimpleAdapter to bind values to views.

### Inherited constants
From interface `android.widget.Adapter`
`int` | `IGNORE_ITEM_VIEW_TYPE` An item view type that causes the `AdapterView` to ignore the item view.
`int` | `NO_SELECTION`

### Public constructors
`SimpleAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to)` Constructor

### Public methods
`int` | `getCount()` How many items are in the data set represented by this Adapter.
`View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
`Resources.Theme` | `getDropDownViewTheme()` Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.
`Filter` | `getFilter()` Returns a filter that can be used to constrain data with a filtering pattern.
`Object` | `getItem(int position)` Get the data item associated with the specified position in the data set.
`long` | `getItemId(int position)` Get the row id associated with the specified position in the list.
`View` | `getView(int position, View convertView, ViewGroup parent)` Get a View that displays the data at the specified position in the data set.
`SimpleAdapter.ViewBinder` | `getViewBinder()` Returns the `ViewBinder` used to bind data to views.
`void` | `setDropDownViewResource(int resource)` Sets the layout resource to create the drop down views.
`void` | `setDropDownViewTheme(Resources.Theme theme)` Sets the `Resources.Theme` against which drop-down views are inflated.
`void` | `setViewBinder(SimpleAdapter.ViewBinder viewBinder)` Sets the binder used to bind data to views.
`void` | `setViewImage(ImageView v, int value)` 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.
`void` | `setViewImage(ImageView v, String value)` 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.
`void` | `setViewText(TextView v, String text)` 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.

### Inherited methods
From class `android.widget.BaseAdapter`
`boolean` | `areAllItemsEnabled()` Indicates whether all the items in this adapter are enabled.
`CharSequence[]` | `getAutofillOptions()` Gets a string representation of the adapter data that can help `AutofillService` autofill the view backed by the adapter.
`View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
`int` | `getItemViewType(int position)` Get the type of View that will be created by `getView(int, View, ViewGroup)` for the specified item.
`int` | `getViewTypeCount()` Returns the number of types of Views that will be created by `getView(int, View, ViewGroup)`.
`boolean` | `hasStableIds()` Indicates whether the item ids are stable across changes to the underlying data.
`boolean` | `isEmpty()`
`boolean` | `isEnabled(int position)` Returns true if the item at the specified position is not a separator.
`void` | `notifyDataSetChanged()` Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
`void` | `notifyDataSetInvalidated()` Notifies the attached observers that the underlying data is no longer valid or available.
`void` | `registerDataSetObserver(DataSetObserver observer)` Register an observer that is called when changes happen to the data used by this adapter.
`void` | `setAutofillOptions(CharSequence... options)` Sets the value returned by `getAutofillOptions()`
`void` | `unregisterDataSetObserver(DataSetObserver observer)` Unregister an observer that has previously been registered with this adapter via `registerDataSetObserver(DataSetObserver)`.
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.
From interface `android.widget.ListAdapter`
`abstract boolean` | `areAllItemsEnabled()` Indicates whether all the items in this adapter are enabled.
`abstract boolean` | `isEnabled(int position)` Returns true if the item at the specified position is not a separator.
From interface `android.widget.SpinnerAdapter`
`abstract View` | `getDropDownView(int position, View convertView, ViewGroup parent)` Gets a `View` that displays in the drop down popup the data at the specified position in the data set.
From interface `android.widget.Filterable`
`abstract Filter` | `getFilter()` Returns a filter that can be used to constrain data with a filtering pattern.
From interface `android.widget.ThemedSpinnerAdapter`
`abstract Resources.Theme` | `getDropDownViewTheme()` Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.
`abstract void` | `setDropDownViewTheme(Resources.Theme theme)` Sets the `Resources.Theme` against which drop-down views are inflated.
From interface `android.widget.Adapter`
`default CharSequence[]` | `getAutofillOptions()` Gets a string representation of the adapter data that can help `AutofillService` autofill the view backed by the adapter.
`abstract int` | `getCount()` How many items are in the data set represented by this Adapter.
`abstract Object` | `getItem(int position)` Get the data item associated with the specified position in the data set.
`abstract long` | `getItemId(int position)` Get the row id associated with the specified position in the list.
`abstract int` | `getItemViewType(int position)` Get the type of View that will be created by `getView(int, View, ViewGroup)` for the specified item.
`abstract View` | `getView(int position, View convertView, ViewGroup parent)` Get a View that displays the data at the specified position in the data set.
`abstract int` | `getViewTypeCount()` Returns the number of types of Views that will be created by `getView(int, View, ViewGroup)`.
`abstract boolean` | `hasStableIds()` Indicates whether the item ids are stable across changes to the underlying data.
`abstract boolean` | `isEmpty()`
`abstract void` | `registerDataSetObserver(DataSetObserver observer)` Register an observer that is called when changes happen to the data used by this adapter.
`abstract void` | `unregisterDataSetObserver(DataSetObserver observer)` Unregister an observer that has previously been registered with this adapter via `registerDataSetObserver(DataSetObserver)`.

## Public constructors

### SimpleAdapter

    public SimpleAdapter (Context context,
                    List<? extends Map<String, ?>> data,
                    int resource,
                    String[] from,
                    int[] to)

Constructor

Parameters
`context` | `Context`: The context where the View associated with this SimpleAdapter is running
`data` | `List`: 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` | `int`: 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` | `String`: A list of column names that will be added to the Map associated with each item.
`to` | `int`: 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.

## Public methods

### getCount

    public int getCount ()

How many items are in the data set represented by this Adapter.

Returns
`int` | Count of items.

See also:

- `Adapter.getCount()`

### getDropDownView

    public View getDropDownView (int position,
                    View convertView,
                    ViewGroup parent)

Gets a `View` that displays in the drop down popup the data at the specified position in the data set.

Parameters
`position` | `int`: index of the item whose view we want.
`convertView` | `View`: 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` | `ViewGroup`: the parent that this view will eventually be attached to

Returns
`View` | a `View` corresponding to the data at the specified position.

### getDropDownViewTheme

    public Resources.Theme getDropDownViewTheme ()

Returns the value previously set by a call to `setDropDownViewTheme(android.content.res.Resources.Theme)`.

Returns
`Resources.Theme` | the `Resources.Theme` against which drop-down views are inflated, or `null` if one has not been explicitly set

### getFilter

    public Filter getFilter ()

Returns a filter that can be used to constrain data with a filtering pattern.

This method is usually implemented by `Adapter` classes.

Returns
`Filter` | a filter used to constrain data

### getItem

    public Object getItem (int position)

Get the data item associated with the specified position in the data set.

Parameters
`position` | `int`: Position of the item whose data we want within the adapter's data set.

Returns
`Object` | The data at the specified position.

See also:

- `Adapter.getItem(int)`

### getItemId

    public long getItemId (int position)

Get the row id associated with the specified position in the list.

Parameters
`position` | `int`: The position of the item within the adapter's data set whose row id we want.

Returns
`long` | The id of the item at the specified position.

See also:

- `Adapter.getItemId(int)`

### getView

    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 `LayoutInflater.inflate(int, android.view.ViewGroup, boolean)` to specify a root view and to prevent attachment to the root.

Parameters
`position` | `int`: The position of the item within the adapter's data set of the item whose view we want.
`convertView` | `View`: 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 `BaseAdapter.getViewTypeCount()` and `BaseAdapter.getItemViewType(int)`).
`parent` | `ViewGroup`: The parent that this view will eventually be attached to

Returns
`View` | A View corresponding to the data at the specified position.

See also:

- `Adapter.getView(int, View, ViewGroup)`

### getViewBinder

    public SimpleAdapter.ViewBinder getViewBinder ()

Returns the `ViewBinder` used to bind data to views.

Returns
`SimpleAdapter.ViewBinder` | a ViewBinder or null if the binder does not exist

See also:

- `setViewBinder(android.widget.SimpleAdapter.ViewBinder)`

### setDropDownViewResource

    public void setDropDownViewResource (int resource)

Sets the layout resource to create the drop down views.

Parameters
`resource` | `int`: the layout resource defining the drop down views

See also:

- `getDropDownView(int, android.view.View, android.view.ViewGroup)`

### setDropDownViewTheme

    public void setDropDownViewTheme (Resources.Theme theme)

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.

Parameters
`theme` | `Resources.Theme`: the theme against which to inflate drop-down views or `null` to use the theme from the adapter's context

See also:

- `getDropDownView(int, View, ViewGroup)`

### setViewBinder

    public void setViewBinder (SimpleAdapter.ViewBinder viewBinder)

Sets the binder used to bind data to views.

Parameters
`viewBinder` | `SimpleAdapter.ViewBinder`: the binder used to bind data to views, can be null to remove the existing binder

See also:

- `getViewBinder()`

### setViewImage

    public void setViewImage (ImageView v,
                    int value)

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(android.widget.ImageView, java.lang.String)` if the supplied data is an int or Integer.

Parameters
`v` | `ImageView`: ImageView to receive an image
`value` | `int`: the value retrieved from the data set

See also:

- `setViewImage(ImageView, String)`

### setViewImage

    public void setViewImage (ImageView v,
                    String value)

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(android.widget.ImageView, int)` if the supplied data is not an int or Integer.

Parameters
`v` | `ImageView`: ImageView to receive an image
`value` | `String`: the value retrieved from the data set

See also:

- `setViewImage(ImageView, int)`

### setViewText

    public void setViewText (TextView v,
                    String text)

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.

Parameters
`v` | `TextView`: TextView to receive text
`text` | `String`: the text to be set for the TextView

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*