This article translated from: http://developer.android.com/reference/android/widget/ArrayAdapter.html
Inheritance relationship
Java. Lang. Object
| ___ Android. widget. baseadapter
| ___ Android. widget. arrayadapter <t>
Class Overview
Returns a specific baseadapter class through an array of any type of objects. By default, this class is expected to provide it with a reference to the textview resource ID. If you want to use a more complex layout, you must use a constructor with the resource ID parameter. This resource ID should be a reference to textview in a large layout resource.
However, the referenced textview object is filled with the tostring () method of each object in the array. You can add a list or array of custom objects. Override the tostring () method of your object to determine the text to be displayed in the list project.
To use a visual component other than textview to display the array content, such as imageview, or to fill in data other than the tostring () result into the view, you must override getview (INT, view, viewgroup) method to return the type you want.
Inherited Constants |
Constant from the Android. widget. Adapter Interface |
Public Constructors |
|
Public arrayadapter (context, int textviewresourceid) Parameter: context Context Textviewresourceid is the resource ID of textview contained in the layout file, which is used when the view is instantiated. |
|
Public arrayadapter (context, int resource, int textviewresourceid) Parameter: context Context Resource is the resource ID of a layout file, which contains the layout used when the view is instantiated. Textviewresourceid: Enter the ID of the textview resource inside the layout resource. |
|
Public arrayadapter (context, int textviewresourceid, t [] objects) Parameter: context Context Textviewresourceid specifies the ID of the textview resource contained in the layout file, which is used when the view object is instantiated. Objects indicates the object in listview. |
|
Public arrayadapter (context, int resource, int textviewresourceid, t [] objects) Parameter: context Context Resource is the resource ID of a layout file, which contains the layout used when the view is instantiated. Textviewresourceid specifies the ID of the textview resource contained in the layout file, which is used when the view object is instantiated. Objects indicates the object in listview. |
|
Public arrayadapter (context, int textviewresourceid, list <t> objects) Parameter: context Context Textviewresourceid specifies the ID of the textview resource contained in the layout file, which is used when the view object is instantiated. Objects indicates the object in listview. |
|
Public arrayadapter (context, int resource, int textviewresourceid, list <t> objects) Parameter: context Context Resource is the resource ID of a layout file, which contains the layout used when the view is instantiated. Textviewresourceid specifies the ID of the textview resource contained in the layout file, which is used when the view object is instantiated. Objects indicates the object in listview. |
Public Methods |
Void |
Add (t object) Add the specified object to the end of the array. Parameter: Object specifies the object to be added to the end of the array. |
Void |
Addall (collection <? Extends T> collection) Adds the specified data set to the end of the array. Parameter: Collection specifies the data set to be added to the end of the array. |
Void |
Addall (T... Items) Add the specified project to the end of the array Parameter: items specifies the data item to be added to the end of the array. |
Void |
Clear () Delete all elements from the list. |
Static Arrayadapter <charsequence> |
Createfromresource (context, int textarrayresid, int textviewresid) Use external resources to create a new arrayadapter. The gettextarray (INT) method is used to obtain the array content. Parameter: Context Environment of the context application. Textarrayresid is used to identify the array of the data source. Textviewresid is used to create the layout identifier of the view. Returned value: arrayadapter |
Context |
Getcontext () Returns the context associated with the array adapter. This context environment is used to create a view that is passed to the constructor from the resource. Returned value: the context associated with the adapter. |
Int |
Getcount () |
View |
Getdropdownview (INT position, view convertview, viewgroup parent) Obtain the visible component at the specified position in the pop-up drop-down list. Parameter: Position: Index of the visible component project we want to obtain Convertview, if possible, specifies an old reusable view object. Note: You should check whether the view is empty and the type is appropriate before using it. If it cannot convert the view to display the correct data, this method can create a new view object. The parent object bound to the view. The returned value is the view object corresponding to the data at the specified position. |
Filter |
Getfilter () Returns a filter (with a filtering mode) used to restrict data ). This method is usually implemented by the adapter class. The return value is used to restrict data filters. |
T |
Getitem (INT position) |
Long |
Getitemid (INT position) |
Int |
Getposition (T item) Returns the index of the project in the specified array. Item Returns the index of the specified project. |
View |
Getview (INT position, view converview, viewgroup parent) |
Void |
Insert (t object, int index) Insert the specified object at the index position in the specified array. Parameter: the object to be inserted into the Array Index location where the index object must be inserted |
Void |
Notifydatasetchanged () Notify the bound observer that the data has changed. Any view that reflects the dataset should refresh itself. |
Void |
Remove (t object) Delete the executed object from the array Parameter: object to be deleted |
Void |
Setdropdownviewresource (INT Resource) Set layout resources to create a drop-down view Parameter resource defines the layout resource of the drop-down view |
Void |
Setnotifyonchange (Boolean notifyonchange) Determines whether the notifydatasetchanged () method is automatically called by adding (t), insert (T, INT), remove (t), clear (), and so on. If it is set to false, the caller must manually call the yydatasetchanged () method to reflect the changes to the bound view. The default value is true, and the flag is reset to true after the yydatasetchanged () method is called. Parameter: If notifyonchange is true, the notifydatasetchanged () method is automatically called for list editing. |
Void |
Sort (comparator <? Super T> comparator) Sorts the contents of the adapter using the specified comparator. Parameter: the comparator used to sort and compare objects contained in the adapter. |