java.lang.Object | ||
↳ | android.widget.BaseAdapter | |
↳ | greendroid.widget.ItemAdapter |
A ListAdapter that acts like an ArrayAdapter. An ItemAdapter manages a
ListView that is backed by an array of Item
s. This is more advanced
than a simple ArrayAdapter because it handles different types of itemviews
internally. Adding, removing items from the internal array is also possible.
The ListView can be notified of underlying data changes manually using
notifyDataSetChanged or automatically using the
setNotifyOnChange(boolean)
method.
Finally, an ItemAdapter can be created via XML code using the
createFromXml(Context, int)
method. This is a very powerful feature
when you want to display static data or if you want to pre-populate your
ItemAdapter.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.widget.Adapter
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs an empty ItemAdapter.
| |||||||||||
Constructs an ItemAdapter using the specified items.
| |||||||||||
Constructs an ItemAdapter using the specified items.
| |||||||||||
Constructs an ItemAdapter using the specified items.
| |||||||||||
Constructs an ItemAdapter using the specified items.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified object at the end of the array.
| |||||||||||
Remove all elements from the list.
| |||||||||||
Creates an ItemAdapter from a given resource ID
| |||||||||||
Creates an ItemAdapter from a given XML document.
| |||||||||||
Returns the current number of different views types used in this
ItemAdapter.
| |||||||||||
Returns the context associated with this array adapter.
| |||||||||||
Inserts the specified object at the specified index in the array.
| |||||||||||
Removes the specified object from the array.
| |||||||||||
Control whether methods that change the list (
add(Item) ,
insert(Item, int) , remove(Item) , 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.ListAdapter
| |||||||||||
From interface
android.widget.SpinnerAdapter
|
Constructs an empty ItemAdapter.
context | The context associated with this array adapter. |
---|
Constructs an ItemAdapter using the specified items.
Note: Using this constructor implies the internal array will be immutable. As a result, adding or removing items will result in an exception.
context | The context associated with this array adapter. |
---|---|
items | The array of Item s use as underlying data for this
ItemAdapter
|
Constructs an ItemAdapter using the specified items.
Note: Using this constructor implies the internal array will be immutable. As a result, adding or removing items will result in an exception.
Note: A ListAdapter doesn't handle variable view type count (even after a notifyDataSetChanged). An ItemAdapter handles several types of cell are therefore use a trick to overcome the previous problem. This trick is to fool the ListView several types exist. If you already know the number of item types you'll possibly have, simply set it using this method
context | The context associated with this array adapter. |
---|---|
items | The array of Item s use as underlying data for this
ItemAdapter |
maxViewTypeCount | The maximum number of view type that may be generated by this ItemAdapter |
Constructs an ItemAdapter using the specified items.
context | The context associated with this array adapter. |
---|---|
items | The list of Item s used as data for this ItemAdapter
|
Constructs an ItemAdapter using the specified items.
Note: A ListAdapter doesn't handle variable view type count (even after a notifyDataSetChanged). An ItemAdapter handles several types of cell are therefore use a trick to overcome the previous problem. This trick is to fool the ListView several types exist. If you already know the number of item types you'll possibly have, simply set it using this method
context | The context associated with this array adapter. |
---|---|
items | The list of Items used as data for this ItemAdapter |
maxViewTypeCount | The maximum number of view type that may be generated by this ItemAdapter |
Adds the specified object at the end of the array.
item | The object to add at the end of the array. |
---|
Remove all elements from the list.
Creates an ItemAdapter from a given resource ID
context | The Context in which the ItemAdapter will be used in |
---|---|
xmlId | The resource ID of an XML file that describes a set of
Item |
XmlPullParserException | |
IOException | |
XmlPullParserException |
Creates an ItemAdapter from a given XML document. Called on a parser positioned at a tag in an XML document, tries to create an ItemAdapter from that tag.
context | The Context in which the ItemAdapter will be used in |
---|---|
parser | The XmlPullParser |
XmlPullParserException | |
IOException | |
XmlPullParserException |
Returns the current number of different views types used in this ItemAdapter. Having a getCurrentViewTypeCount equal to getViewTypeCount means you won't be able to add a new type of view in this adapter (The Adapter class doesn't allow variable view type count).
Returns the context associated with this array adapter. The context is used to create Views from the resource passed to the constructor.
Inserts the specified object at the specified index in the array.
item | The object to insert into the array. |
---|---|
index | The index at which the object must be inserted. |
Removes the specified object from the array.
item | The object to remove. |
---|
Control whether methods that change the list (add(Item)
,
insert(Item, int)
, remove(Item)
, 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. |
---|