java.lang.Object | ||
↳ | android.widget.BaseAdapter | |
↳ | android.widget.ArrayAdapter<T> |
A concrete BaseAdapter that is backed by an array of arbitrary objects. By default this class expects that the provided resource id references a single TextView. If you want to use a more complex layout, use the constructors that also takes a field id. That field id should reference a TextView in the larger layout resource.
However the TextView is referenced, it will be filled with the toString() of each object in the array. You can add lists or arrays of custom objects. Override the toString() method of your objects to determine what text will be displayed for the item in the list.
To use something other than TextViews for the array display, for instance, ImageViews,
or to have some of data besides toString() results fill the views,
override
getView(int, View, ViewGroup)
to return the type of view you want.
[Expand]
Inherited Constants
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.widget.Adapter
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Constructor
|
||||||||||
|
Constructor
|
||||||||||
|
Constructor
|
||||||||||
|
Constructor
|
||||||||||
|
Constructor
|
||||||||||
|
Constructor
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Adds the specified object at the end of the array.
|
||||||||||
|
Adds the specified Collection at the end of the array.
|
||||||||||
|
Adds the specified items at the end of the array.
|
||||||||||
|
Remove all elements from the list.
|
||||||||||
|
Creates a new ArrayAdapter from external resources.
|
||||||||||
|
Returns the context associated with this array adapter.
|
||||||||||
|
|
||||||||||
|
Get a
|
||||||||||
|
Returns a filter that can be used to constrain data with a filtering pattern. |
||||||||||
|
|
||||||||||
|
|
||||||||||
|
Returns the position of the specified item in the array.
|
||||||||||
|
|
||||||||||
|
Inserts the specified object at the specified index in the array.
|
||||||||||
|
Notifies the attached observers that the underlying data has been changed
and any View reflecting the data set should refresh itself.
|
||||||||||
|
Removes the specified object from the array.
|
||||||||||
|
Sets the layout resource to create the drop down views. |
||||||||||
|
Control whether methods that change the list (
add(T)
,
insert(T, int)
,
remove(T)
,
clear()
) automatically call
notifyDataSetChanged()
.
|
||||||||||
|
Sorts the content of this adapter using the specified comparator.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.BaseAdapter
|
|||||||||||
From class
java.lang.Object
|
|||||||||||
From interface
android.widget.Adapter
|
|||||||||||
From interface
android.widget.Filterable
|
|||||||||||
From interface
android.widget.ListAdapter
|
|||||||||||
From interface
android.widget.SpinnerAdapter
|
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a TextView to use when instantiating views. |
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a layout to use when instantiating views. |
textViewResourceId | The id of the TextView within the layout resource to be populated |
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a TextView to use when instantiating views. |
objects | The objects to represent in the ListView. |
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a layout to use when instantiating views. |
textViewResourceId | The id of the TextView within the layout resource to be populated |
objects | The objects to represent in the ListView. |
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a TextView to use when instantiating views. |
objects | The objects to represent in the ListView. |
Constructor
context | The current context. |
---|---|
resource | The resource ID for a layout file containing a layout to use when instantiating views. |
textViewResourceId | The id of the TextView within the layout resource to be populated |
objects | The objects to represent in the ListView. |
Adds the specified object at the end of the array.
object | The object to add at the end of the array. |
---|
Adds the specified Collection at the end of the array.
collection | The Collection to add at the end of the array. |
---|
Adds the specified items at the end of the array.
items | The items to add at the end of the array. |
---|
Creates a new ArrayAdapter from external resources. The content of the array is
obtained through
getTextArray(int)
.
context | The application's environment. |
---|---|
textArrayResId | The identifier of the array to use as the data source. |
textViewResId | The identifier of the layout used to create views. |
Returns the context associated with this array adapter. The context is used to create views from the resource passed to the constructor.
Get 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 a filter that can be used to constrain data with a filtering pattern.
This method is usually implemented by
Adapter
classes.
Returns the position of the specified item in the array.
item | The item to retrieve the position of. |
---|
Inserts the specified object at the specified index in the array.
object | The object to insert into the array. |
---|---|
index | The index at which the object must be inserted. |
Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.
Removes the specified object from the array.
object | The object to remove. |
---|
Sets the layout resource to create the drop down views.
resource | the layout resource defining the drop down views |
---|
Control whether methods that change the list (
add(T)
,
insert(T, int)
,
remove(T)
,
clear()
) automatically call
notifyDataSetChanged()
. If set to false, caller must
manually call notifyDataSetChanged() to have the changes
reflected in the attached view.
The default is true, and calling notifyDataSetChanged()
resets the flag to true.
notifyOnChange |
if true, modifications to the list will
automatically call
notifyDataSetChanged()
|
---|
Sorts the content of this adapter using the specified comparator.
comparator | The comparator used to sort the objects contained in this adapter. |
---|