| java.lang.Object | |||||
| ↳ | android.view.View | ||||
| ↳ | android.view.ViewGroup | ||||
| ↳ | android.widget.AdapterView<T extends android.widget.Adapter> | ||||
| ↳ | android.widget.AbsListView | ||||
| ↳ | android.widget.ListView | ||||
Known Direct Subclasses
|
A view that shows items in a vertically scrolling list. The items
come from the ListAdapter associated with this view.
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| ListView.FixedViewInfo | A class that represents a fixed view in a list, for example a header at the top or a footer at the bottom. | ||||||||||
| XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| android:choiceMode | Defines the choice behavior for the ListView. | ||||||||||
| android:divider | Drawable or color to draw between list items. | ||||||||||
| android:dividerHeight | Height of the divider. | ||||||||||
| android:entries | Reference to an array resource that will populate the ListView. | ||||||||||
| android:footerDividersEnabled | When set to false, the ListView will not draw the divider before each footer view. | ||||||||||
| android:headerDividersEnabled | When set to false, the ListView will not draw the divider after each header view. | ||||||||||
|
[Expand]
Inherited XML Attributes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.AbsListView
| |||||||||||
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
| |||||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | CHOICE_MODE_MULTIPLE | The list allows multiple choices | |||||||||
| int | CHOICE_MODE_NONE | Normal list that does not indicate choices | |||||||||
| int | CHOICE_MODE_SINGLE | The list allows up to one choice | |||||||||
|
[Expand]
Inherited Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.widget.AbsListView
| |||||||||||
From class
android.widget.AdapterView
| |||||||||||
From class
android.view.ViewGroup
| |||||||||||
From class
android.view.View
| |||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Add a fixed view to appear at the bottom of the list.
| |||||||||||
Add a fixed view to appear at the bottom of the list.
| |||||||||||
Add a fixed view to appear at the top of the list.
| |||||||||||
Add a fixed view to appear at the top of the list.
| |||||||||||
Clear any choices previously set
| |||||||||||
Dispatch a key event to the next view on the focus path.
| |||||||||||
Dispatches an
AccessibilityEvent to the View children
to be populated. | |||||||||||
Returns the adapter currently in use in this ListView.
| |||||||||||
Returns the set of checked items ids.
| |||||||||||
Returns the currently checked item.
| |||||||||||
Returns the set of checked items in the list.
| |||||||||||
Returns the drawable that will be drawn between each item in the list.
| |||||||||||
Returns the number of footer views in the list.
| |||||||||||
Returns the number of header views in the list.
| |||||||||||
Returns the checked state of the specified position.
| |||||||||||
Default implementation of
KeyEvent.Callback.onKeyMultiple(): perform press of the view
when KEYCODE_DPAD_CENTER or KEYCODE_ENTER
is released, if the view is enabled and clickable. | |||||||||||
Default implementation of
KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event). | |||||||||||
Default implementation of
KeyEvent.Callback.onKeyMultiple(): perform clicking of the view
when KEYCODE_DPAD_CENTER or
KEYCODE_ENTER is released. | |||||||||||
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
onSaveInstanceState(). | |||||||||||
Hook allowing a view to generate a representation of its internal state
that can later be used to create a new instance with that same state.
| |||||||||||
Implement this method to handle touch screen motion events.
| |||||||||||
Call the OnItemClickListener, if it is defined.
| |||||||||||
Removes a previously-added footer view.
| |||||||||||
Removes a previously-added header view.
| |||||||||||
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
| |||||||||||
Sets the data behind this ListView.
| |||||||||||
When set to a non-zero value, the cache color hint indicates that this list is always drawn
on top of a solid, single-color, opaque background
| |||||||||||
Defines the choice behavior for the List.
| |||||||||||
Sets the drawable that will be drawn between each item in the list.
| |||||||||||
Sets the height of the divider that will be drawn between each item in the list.
| |||||||||||
Enables or disables the drawing of the divider for footer views.
| |||||||||||
Enables or disables the drawing of the divider for header views.
| |||||||||||
Sets the checked state of the specified position.
| |||||||||||
Indicates that the views created by the ListAdapter can contain focusable
items.
| |||||||||||
Sets the currently selected item.
| |||||||||||
setSelectionAfterHeaderView set the selection to be the first list item
after the header views.
| |||||||||||
Sets the selected item and positions the selection y pixels from the top edge
of the ListView.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Indicates whether the view group has the ability to animate its children
after the first layout.
| |||||||||||
Called by draw to draw the child views.
| |||||||||||
Subclasses must override this method to layout their children.
| |||||||||||
Finalize inflating a view from XML.
| |||||||||||
Called by the view system when the focus state of this view changes.
| |||||||||||
Measure the view and its content to determine the measured width and the measured height. | |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class android.widget.AbsListView
| |||||||||||
From class android.widget.AdapterView
| |||||||||||
From class android.view.ViewGroup
| |||||||||||
From class android.view.View
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface android.graphics.drawable.Drawable.Callback
| |||||||||||
From interface android.text.TextWatcher
| |||||||||||
From interface android.view.KeyEvent.Callback
| |||||||||||
From interface android.view.ViewManager
| |||||||||||
From interface android.view.ViewParent
| |||||||||||
From interface android.view.ViewTreeObserver.OnGlobalLayoutListener
| |||||||||||
From interface android.view.ViewTreeObserver.OnTouchModeChangeListener
| |||||||||||
From interface android.view.accessibility.AccessibilityEventSource
| |||||||||||
From interface android.widget.Filter.FilterListener
| |||||||||||
Defines the choice behavior for the ListView. By default, lists do not have any choice behavior. By setting the choiceMode to singleChoice, the List allows up to one item to be in a chosen state. By setting the choiceMode to multipleChoice, the list allows any number of items to be chosen.
Must be one of the following constant values.
| Constant | Value | Description |
|---|---|---|
none | 0 | Normal list that does not indicate choices. |
singleChoice | 1 | The list allows up to one choice. |
multipleChoice | 2 | The list allows multiple choices. |
This corresponds to the global attribute resource symbol choiceMode.
Drawable or color to draw between list items.
May be a reference to another resource, in the form "@[+][package:]type:name"
or to a theme attribute in the form "?[package:][type:]name".
May be a color value, in the form of "#rgb", "#argb",
"#rrggbb", or "#aarrggbb".
This corresponds to the global attribute resource symbol divider.
Height of the divider. Will use the intrinsic height of the divider if this is not specified.
Must be a dimension value, which is a floating point number appended with a unit such as "14.5sp".
Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size),
in (inches), mm (millimeters).
This may also be a reference to a resource (in the form
"@[package:]type:name") or
theme attribute (in the form
"?[package:][type:]name")
containing a value of this type.
This corresponds to the global attribute resource symbol dividerHeight.
Reference to an array resource that will populate the ListView. For static content, this is simpler than populating the ListView programmatically.
Must be a reference to another resource, in the form "@[+][package:]type:name"
or to a theme attribute in the form "?[package:][type:]name".
This corresponds to the global attribute resource symbol entries.
When set to false, the ListView will not draw the divider before each footer view. The default value is true.
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form
"@[package:]type:name") or
theme attribute (in the form
"?[package:][type:]name")
containing a value of this type.
This corresponds to the global attribute resource symbol footerDividersEnabled.
When set to false, the ListView will not draw the divider after each header view. The default value is true.
Must be a boolean value, either "true" or "false".
This may also be a reference to a resource (in the form
"@[package:]type:name") or
theme attribute (in the form
"?[package:][type:]name")
containing a value of this type.
This corresponds to the global attribute resource symbol headerDividersEnabled.
The list allows multiple choices
Normal list that does not indicate choices
The list allows up to one choice
Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
| v | The view to add. |
|---|
Add a fixed view to appear at the bottom of the list. If addFooterView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
| v | The view to add. |
|---|---|
| data | Data to associate with this view |
| isSelectable | true if the footer view can be selected |
Add a fixed view to appear at the top of the list. If addHeaderView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
| v | The view to add. |
|---|
Add a fixed view to appear at the top of the list. If addHeaderView is called more than once, the views will appear in the order they were added. Views added using this call can take focus if they want.
NOTE: Call this before calling setAdapter. This is so ListView can wrap the supplied cursor with one that that will also account for header views.
| v | The view to add. |
|---|---|
| data | Data to associate with this view |
| isSelectable | whether the item is selectable |
Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.
| event | The key event to be dispatched. |
|---|
Dispatches an AccessibilityEvent to the View children
to be populated.
| event | The event. |
|---|
Returns the adapter currently in use in this ListView. The returned adapter
might not be the same adapter passed to setAdapter(ListAdapter) but
might be a WrapperListAdapter.
Returns the set of checked items ids. The result is only valid if
the choice mode has not been set to CHOICE_MODE_SINGLE.
Returns the currently checked item. The result is only valid if the choice
mode has been set to CHOICE_MODE_SINGLE.
INVALID_POSITION if nothing is selectedReturns the set of checked items in the list. The result is only valid if
the choice mode has not been set to CHOICE_MODE_NONE.
null if the choice mode is set to
CHOICE_MODE_NONE.
Returns the drawable that will be drawn between each item in the list.
Returns the number of footer views in the list. Footer views are special views at the bottom of the list that should not be recycled during a layout.
Returns the number of header views in the list. Header views are special views at the top of the list that should not be recycled during a layout.
Returns the checked state of the specified position. The result is only
valid if the choice mode has been set to CHOICE_MODE_SINGLE
or CHOICE_MODE_MULTIPLE.
| position | The item whose checked state to return |
|---|
false if choice mode
is invalidDefault implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view
when KEYCODE_DPAD_CENTER or KEYCODE_ENTER
is released, if the view is enabled and clickable.
| keyCode | A key code that represents the button pressed, from
KeyEvent. |
|---|---|
| event | The KeyEvent object that defines the button action. |
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle
the event).
| keyCode | A key code that represents the button pressed, from
KeyEvent. |
|---|---|
| repeatCount | The number of times the action was made. |
| event | The KeyEvent object that defines the button action. |
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view
when KEYCODE_DPAD_CENTER or
KEYCODE_ENTER is released.
| keyCode | A key code that represents the button pressed, from
KeyEvent. |
|---|---|
| event | The KeyEvent object that defines the button action. |
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by onSaveInstanceState(). This function will never be called with a
null state.
| state | The frozen state that had previously been returned by
onSaveInstanceState(). |
|---|
Hook allowing a view to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can not be reconstructed later. For example, you will never store your current position on screen because that will be computed again when a new instance of the view is placed in its view hierarchy.
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
Implement this method to handle touch screen motion events.
| ev | The motion event. |
|---|
Call the OnItemClickListener, if it is defined.
| view | The view within the AdapterView that was clicked. |
|---|---|
| position | The position of the view in the adapter. |
| id | The row id of the item that was clicked. |
Removes a previously-added footer view.
| v | The view to remove |
|---|
Removes a previously-added header view.
| v | The view to remove |
|---|
Called when a child of this group wants a particular rectangle to be
positioned onto the screen. ViewGroups overriding this can trust
that:
ViewGroups overriding this should uphold the contract:
| child | The direct child making the request. |
|---|---|
| rect | The rectangle in the child's coordinates the child wishes to be on the screen. |
| immediate | True to forbid animated or delayed scrolling, false otherwise |