public class

ListView

extends AbsListView
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

Class Overview

A view that shows items in a vertically scrolling list. The items come from the ListAdapter associated with this view.

See the List View tutorial.

Summary

Nested Classes
class 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
Attribute Name Related Method Description
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
[Expand]
Inherited Constants
From class android.widget.AbsListView
From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ListView(Context context)
ListView(Context context, AttributeSet attrs)
ListView(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addFooterView(View v)
Add a fixed view to appear at the bottom of the list.
void addFooterView(View v, Object data, boolean isSelectable)
Add a fixed view to appear at the bottom of the list.
void addHeaderView(View v, Object data, boolean isSelectable)
Add a fixed view to appear at the top of the list.
void addHeaderView(View v)
Add a fixed view to appear at the top of the list.
boolean dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
ListAdapter getAdapter()
Returns the adapter currently in use in this ListView.
long[] getCheckItemIds()
This method is deprecated. Use getCheckedItemIds() instead.
Drawable getDivider()
Returns the drawable that will be drawn between each item in the list.
int getDividerHeight()
int getFooterViewsCount()
Returns the number of footer views in the list.
int getHeaderViewsCount()
Returns the number of header views in the list.
boolean getItemsCanFocus()
int getMaxScrollAmount()
Drawable getOverscrollFooter()
Drawable getOverscrollHeader()
boolean isOpaque()
Indicates whether this View is opaque.
boolean onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyDown(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released, if the view is enabled and clickable.
boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).
boolean onKeyUp(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyUp(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released.
boolean removeFooterView(View v)
Removes a previously-added footer view.
boolean removeHeaderView(View v)
Removes a previously-added header view.
boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate)
Called when a child of this group wants a particular rectangle to be positioned onto the screen.
void setAdapter(ListAdapter adapter)
Sets the data behind this ListView.
void setCacheColorHint(int color)
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.
void setDivider(Drawable divider)
Sets the drawable that will be drawn between each item in the list.
void setDividerHeight(int height)
Sets the height of the divider that will be drawn between each item in the list.
void setFooterDividersEnabled(boolean footerDividersEnabled)
Enables or disables the drawing of the divider for footer views.
void setHeaderDividersEnabled(boolean headerDividersEnabled)
Enables or disables the drawing of the divider for header views.
void setItemsCanFocus(boolean itemsCanFocus)
Indicates that the views created by the ListAdapter can contain focusable items.
void setOverscrollFooter(Drawable footer)
Sets the drawable that will be drawn below all other list content.
void setOverscrollHeader(Drawable header)
Sets the drawable that will be drawn above all other list content.
void setRemoteViewsAdapter(Intent intent)
Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService through the specified intent.
void setSelection(int position)
Sets the currently selected item.
void setSelectionAfterHeaderView()
setSelectionAfterHeaderView set the selection to be the first list item after the header views.
void setSelectionFromTop(int position, int y)
Sets the selected item and positions the selection y pixels from the top edge of the ListView.
void smoothScrollByOffset(int offset)
Smoothly scroll to the specified adapter position offset.
void smoothScrollToPosition(int position)
Smoothly scroll to the specified adapter position.
Protected Methods
boolean canAnimate()
Indicates whether the view group has the ability to animate its children after the first layout.
void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
boolean drawChild(Canvas canvas, View child, long drawingTime)
Draw one child of this View Group.
View findViewTraversal(int id)
View findViewWithTagTraversal(Object tag)
void layoutChildren()
Subclasses must override this method to layout their children.
void onFinishInflate()
Finalize inflating a view from XML.
void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

void onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
[Expand]
Inherited Methods
From class android.widget.AbsListView
From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View