Build 1.0_r1(from source)

android.widget
Class ListView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.AdapterView<ListAdapter>
              extended by android.widget.AbsListView
                  extended by android.widget.ListView
All Implemented Interfaces:
Drawable.Callback, TextWatcher, KeyEvent.Callback, ViewManager, ViewParent, ViewTreeObserver.OnGlobalLayoutListener, ViewTreeObserver.OnTouchModeChangeListener, Filter.FilterListener
Direct Known Subclasses:
ExpandableListView

public class ListView
extends AbsListView

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


Nested Class Summary
(package private)  class ListView.FixedViewInfo
           
(package private) static class ListView.SavedState
           
 
Nested classes/interfaces inherited from class android.widget.AbsListView
AbsListView.CheckForTap, AbsListView.LayoutParams, AbsListView.OnScrollListener, AbsListView.RecycleBin, AbsListView.RecyclerListener
 
Nested classes/interfaces inherited from class android.widget.AdapterView
AdapterView.AdapterContextMenuInfo, AdapterView.AdapterDataSetObserver, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener, AdapterView.OnItemSelectedListener
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
static int CHOICE_MODE_MULTIPLE
          The list allows multiple choices
static int CHOICE_MODE_NONE
          Normal list that does not indicate choices
static int CHOICE_MODE_SINGLE
          The list allows up to one choice
(package private)  Drawable mDivider
           
(package private)  int mDividerHeight
           
(package private) static int NO_POSITION
          Used to indicate a no preference for a position type.
 
Fields inherited from class android.widget.AbsListView
LAYOUT_FORCE_BOTTOM, LAYOUT_FORCE_TOP, LAYOUT_MOVE_SELECTION, LAYOUT_NORMAL, LAYOUT_SET_SELECTION, LAYOUT_SPECIFIC, LAYOUT_SYNC, mAdapter, mCachingStarted, mDataSetObserver, mDrawSelectorOnTop, mLastY, mLayoutMode, mListPadding, mMotionCorrection, mMotionPosition, mMotionViewNewTop, mMotionViewOriginalTop, mMotionX, mMotionY, mPopup, mRecycler, mResurrectToPosition, mScrollDown, mScrollingCacheEnabled, mScrollUp, mSelectedTop, mSelectionBottomPadding, mSelectionLeftPadding, mSelectionRightPadding, mSelectionTopPadding, mSelector, mSelectorRect, mStackFromBottom, mTextFilter, mTouchMode, mWidthMeasureSpec, TOUCH_MODE_DONE_WAITING, TOUCH_MODE_DOWN, TOUCH_MODE_FLING, TOUCH_MODE_REST, TOUCH_MODE_SCROLL, TOUCH_MODE_TAP, TRANSCRIPT_MODE_ALWAYS_SCROLL, TRANSCRIPT_MODE_DISABLED, TRANSCRIPT_MODE_NORMAL
 
Fields inherited from class android.widget.AdapterView
INVALID_POSITION, INVALID_ROW_ID, ITEM_VIEW_TYPE_HEADER_OR_FOOTER, ITEM_VIEW_TYPE_IGNORE, mBlockLayoutRequests, mDataChanged, mEmptyView, mFirstPosition, mInLayout, mItemCount, mNeedSync, mNextSelectedPosition, mNextSelectedRowId, mOldItemCount, mOldSelectedPosition, mOldSelectedRowId, mOnItemClickListener, mOnItemLongClickListener, mOnItemSelectedListener, mSelectedPosition, mSelectedRowId, mSpecificTop, mSyncHeight, mSyncMode, mSyncPosition, mSyncRowId, SYNC_FIRST_POSITION, SYNC_MAX_DURATION_MILLIS, SYNC_SELECTED_POSITION
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mLocation, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
ListView(Context context)
           
ListView(Context context, AttributeSet attrs)
           
ListView(Context context, AttributeSet attrs, int defStyle)
           
 
Method Summary
 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)
          Add a fixed view to appear at the top of the list.
 void addHeaderView(View v, Object data, boolean isSelectable)
          Add a fixed view to appear at the top of the list.
(package private)  boolean arrowScroll(int direction)
          Scrolls to the next or previous item if possible.
protected  boolean canAnimate()
          Indicates whether the view group has the ability to animate its children after the first layout.
 void clearChoices()
          Clear any choices previously set
protected  void dispatchDraw(Canvas canvas)
          Called by draw to draw the child views.
 boolean dispatchKeyEvent(KeyEvent event)
          Dispatch a key event to the next view on the focus path.
(package private)  void drawDivider(Canvas canvas, Rect bounds, int childIndex)
          Draws a divider for the given child in the given bounds.
(package private)  void fillGap(boolean down)
          Fills the gap left open by a touch-scroll.
(package private)  int findMotionRow(int y)
          Find the row closest to y.
(package private)  View findViewInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where, int id)
           
(package private)  View findViewTagInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where, Object tag)
           
protected  View findViewTraversal(int id)
          
protected  View findViewWithTagTraversal(Object tag)
          
(package private)  boolean fullScroll(int direction)
          Go to the last or first item if possible (not worrying about panning across or navigating within the internal focus of the currently selected item.)
 ListAdapter getAdapter()
          Returns the adapter currently in use in this ListView.
 int getCheckedItemPosition()
          Returns the currently checked item.
 SparseBooleanArray getCheckedItemPositions()
          Returns the set of checked items in the list.
 int getChoiceMode()
           
 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()
           
 boolean isItemChecked(int position)
          Returns the checked state of the specified position.
protected  void layoutChildren()
           
(package private)  int lookForSelectablePosition(int position, boolean lookDown)
          Find a position that can be selected (i.e., is not a separator).
(package private)  int measureHeightOfChildren(int widthMeasureSpec, int startPosition, int endPosition, int maxHeight, int disallowPartialChildPosition)
          Measures the height of the given range of children (inclusive) and returns the height with this ListView's padding and divider heights included.
protected  void onFinishInflate()
          Finalize inflating a view from XML.
protected  void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
          Called by the view system when the focus state of this view changes.
 boolean onKeyDown(int keyCode, KeyEvent event)
          Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.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.onKeyMultiple(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released.
protected  void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
           Measure the view and its content to determine the measured width and the measured height.
 void onRestoreInstanceState(Parcelable state)
          Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState().
 Parcelable 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.
 boolean onTouchEvent(MotionEvent ev)
          Implement this method to handle touch screen motion events.
(package private)  boolean pageScroll(int direction)
          Scrolls up or down by the number of items currently present on screen.
 boolean performItemClick(View view, int position, long id)
          Call the OnItemClickListener, if it is defined.
 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.
(package private)  void resetList()
          The list is empty.
 void setAdapter(ListAdapter adapter)
          Sets the data behind this ListView.
 void setChoiceMode(int choiceMode)
          Defines the choice behavior for the List.
 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 setItemChecked(int position, boolean value)
          Sets the checked state of the specified position.
 void setItemsCanFocus(boolean itemsCanFocus)
          Indicates that the views created by the ListAdapter can contain focusable items.
 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.
(package private)  void setSelectionInt(int position)
          Makes the item at the supplied position selected.
 
Methods inherited from class android.widget.AbsListView
addTouchables, afterTextChanged, beforeTextChanged, checkLayoutParams, clearTextFilter, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenuInfo, dismissPopup, dispatchSetPressed, drawableStateChanged, generateLayoutParams, generateLayoutParams, getBottomFadingEdgeStrength, getCacheColorHint, getContextMenuInfo, getDistance, getFocusedRect, getListPaddingBottom, getListPaddingLeft, getListPaddingRight, getListPaddingTop, getSelectedView, getSelector, getSolidColor, getTopFadingEdgeStrength, getTranscriptMode, handleDataChanged, hasTextFilter, hideSelector, invalidateViews, invokeOnItemScrollListener, isInFilterMode, isScrollingCacheEnabled, isStackFromBottom, isTextFilterEnabled, keyPressed, obtainView, onAttachedToWindow, onCreateDrawableState, onDetachedFromWindow, onFilterComplete, onGlobalLayout, onInterceptTouchEvent, onLayout, onSizeChanged, onTextChanged, onTouchModeChanged, onWindowFocusChanged, pointToPosition, pointToRowId, positionSelector, reclaimViews, reconcileSelectedPosition, requestLayout, requestLayoutIfNecessary, resurrectSelection, sendToTextFilter, setCacheColorHint, setDrawSelectorOnTop, setFilterText, setOnScrollListener, setRecyclerListener, setScrollIndicators, setScrollingCacheEnabled, setSelector, setSelector, setStackFromBottom, setTextFilterEnabled, setTranscriptMode, shouldShowSelector, showContextMenuForChild, touchModeDrawsInPressedState, trackMotionScroll, updateScrollIndicators, verifyDrawable
 
Methods inherited from class android.widget.AdapterView
addView, addView, addView, addView, checkFocus, checkSelectionChanged, dispatchRestoreInstanceState, dispatchSaveInstanceState, findSyncPosition, getCount, getEmptyView, getFirstVisiblePosition, getItemAtPosition, getItemIdAtPosition, getLastVisiblePosition, getOnItemClickListener, getOnItemLongClickListener, getOnItemSelectedListener, getPositionForView, getSelectedItem, getSelectedItemId, getSelectedItemPosition, rememberSyncState, removeAllViews, removeView, removeViewAt, selectionChanged, setEmptyView, setFocusable, setFocusableInTouchMode, setNextSelectedPositionInt, setOnClickListener, setOnItemClickListener, setOnItemLongClickListener, setOnItemSelectedListener, setSelectedPositionInt
 
Methods inherited from class android.view.ViewGroup
addFocusables, addStatesFromChildren, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchFreezeSelfOnly, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, findFocus, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, generateDefaultLayoutParams, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViewsInLayout, removeDetachedView, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, createContextMenu, debug, debugIndent, destroyDrawingCache, dispatchKeyShortcutEvent, draw, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getContext, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCreateContextMenu, onDraw, onKeyShortcut, onScrollChanged, onSetAlpha, onTrackballEvent, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFrame, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested
 

Field Detail

NO_POSITION

static final int NO_POSITION
Used to indicate a no preference for a position type.

See Also:
Constant Field Values

CHOICE_MODE_NONE

public static final int CHOICE_MODE_NONE
Normal list that does not indicate choices

See Also:
Constant Field Values

CHOICE_MODE_SINGLE

public static final int CHOICE_MODE_SINGLE
The list allows up to one choice

See Also:
Constant Field Values

CHOICE_MODE_MULTIPLE

public static final int CHOICE_MODE_MULTIPLE
The list allows multiple choices

See Also:
Constant Field Values

mDivider

Drawable mDivider

mDividerHeight

int mDividerHeight
Constructor Detail

ListView

public ListView(Context context)

ListView

public ListView(Context context,
                AttributeSet attrs)

ListView

public ListView(Context context,
                AttributeSet attrs,
                int defStyle)
Method Detail

getMaxScrollAmount

public int getMaxScrollAmount()
Returns:
The maximum amount a list view will scroll in response to an arrow event.

addHeaderView

public void addHeaderView(View v,
                          Object data,
                          boolean isSelectable)
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.

Parameters:
v - The view to add.
data - Data to associate with this view
isSelectable - whether the item is selectable

addHeaderView

public void addHeaderView(View v)
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.

Parameters:
v - The view to add.

getHeaderViewsCount

public int getHeaderViewsCount()
Description copied from class: AbsListView
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.

Overrides:
getHeaderViewsCount in class AbsListView
Returns:
The number of header views, 0 in the default implementation.

removeHeaderView

public boolean removeHeaderView(View v)
Removes a previously-added header view.

Parameters:
v - The view to remove
Returns:
true if the view was removed, false if the view was not a header view

addFooterView

public void addFooterView(View v,
                          Object data,
                          boolean isSelectable)
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.

Parameters:
v - The view to add.
data - Data to associate with this view
isSelectable - true if the footer view can be selected

addFooterView

public void addFooterView(View v)
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.

Parameters:
v - The view to add.

getFooterViewsCount

public int getFooterViewsCount()
Description copied from class: AbsListView
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.

Overrides:
getFooterViewsCount in class AbsListView
Returns:
The number of footer views, 0 in the default implementation.

removeFooterView

public boolean removeFooterView(View v)
Removes a previously-added footer view.

Parameters:
v - The view to remove
Returns:
true if the view was removed, false if the view was not a footer view

getAdapter

public ListAdapter getAdapter()
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.

Specified by:
getAdapter in class AdapterView<ListAdapter>
Returns:
The adapter currently used to display data in this ListView.
See Also:
setAdapter(ListAdapter)

setAdapter

public void setAdapter(ListAdapter adapter)
Sets the data behind this ListView. The adapter passed to this method may be wrapped by a WrapperListAdapter, depending on the ListView features currently in use. For instance, adding headers and/or footers will cause the adapter to be wrapped.

Specified by:
setAdapter in class AdapterView<ListAdapter>
Parameters:
adapter - The ListAdapter which is responsible for maintaining the data backing this list and for producing a view to represent an item in that data set.
See Also:
getAdapter()

resetList

void resetList()
The list is empty. Clear everything out.

Overrides:
resetList in class AbsListView

requestChildRectangleOnScreen

public boolean requestChildRectangleOnScreen(View child,
                                             Rect rect,
                                             boolean immediate)
Description copied from class: ViewGroup
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:


fillGap

void fillGap(boolean down)
Fills the gap left open by a touch-scroll. During a touch scroll, children that remain on screen are shifted and the other ones are discarded. The role of this method is to fill the gap thus created by performing a partial layout in the empty space.

Specified by:
fillGap in class AbsListView
Parameters:
down - true if the scroll is going down, false if it is going up

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)
Description copied from class: View

Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling the superclass' View.onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override View.onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (View.getSuggestedMinimumHeight() and View.getSuggestedMinimumWidth()).

Overrides:
onMeasure in class AbsListView
Parameters:
widthMeasureSpec - horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec - vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
See Also:
View.getMeasuredWidth(), View.getMeasuredHeight(), View.setMeasuredDimension(int, int), View.getSuggestedMinimumHeight(), View.getSuggestedMinimumWidth(), View.MeasureSpec.getMode(int), View.MeasureSpec.getSize(int)

measureHeightOfChildren

final int measureHeightOfChildren(int widthMeasureSpec,
                                  int startPosition,
                                  int endPosition,
                                  int maxHeight,
                                  int disallowPartialChildPosition)
Measures the height of the given range of children (inclusive) and returns the height with this ListView's padding and divider heights included. If maxHeight is provided, the measuring will stop when the current height reaches maxHeight.

Parameters:
widthMeasureSpec - The width measure spec to be given to a child's View.measure(int, int).
startPosition - The position of the first child to be shown.
endPosition - The (inclusive) position of the last child to be shown. Specify NO_POSITION if the last child should be the last available child from the adapter.
maxHeight - The maximum height that will be returned (if all the children don't fit in this value, this value will be returned).
disallowPartialChildPosition - In general, whether the returned height should only contain entire children. This is more powerful--it is the first inclusive position at which partial children will not be allowed. Example: it looks nice to have at least 3 completely visible children, and in portrait this will most likely fit; but in landscape there could be times when even 2 children can not be completely shown, so a value of 2 (remember, inclusive) would be good (assuming startPosition is 0).
Returns:
The height of this ListView with the given children.

findMotionRow

int findMotionRow(int y)
Description copied from class: AbsListView
Find the row closest to y. This row will be used as the motion row when scrolling

Specified by:
findMotionRow in class AbsListView
Parameters:
y - Where the user touched
Returns:
The position of the first (or only) item in the row closest to y

layoutChildren

protected void layoutChildren()
Overrides:
layoutChildren in class AbsListView

canAnimate

protected boolean canAnimate()
Description copied from class: ViewGroup
Indicates whether the view group has the ability to animate its children after the first layout.

Overrides:
canAnimate in class AdapterView<ListAdapter>
Returns:
true if the children can be animated, false otherwise

setSelection

public void setSelection(int position)
Sets the currently selected item

Specified by:
setSelection in class AdapterView<ListAdapter>
Parameters:
position - Index (starting at 0) of the data item to be selected. If in touch mode, the item will not be selected but it will still be positioned appropriately.

setSelectionFromTop

public void setSelectionFromTop(int position,
                                int y)
Sets the selected item and positions the selection y pixels from the top edge of the ListView. (If in touch mode, the item will not be selected but it will still be positioned appropriately.)

Parameters:
position - Index (starting at 0) of the data item to be selected.
y - The distance from the top edge of the ListView (plus padding) that the item will be positioned.

setSelectionInt

void setSelectionInt(int position)
Makes the item at the supplied position selected.

Specified by:
setSelectionInt in class AbsListView
Parameters:
position - the position of the item to select

lookForSelectablePosition

int lookForSelectablePosition(int position,
                              boolean lookDown)
Find a position that can be selected (i.e., is not a separator).

Overrides:
lookForSelectablePosition in class AdapterView<ListAdapter>
Parameters:
position - The starting position to look at.
lookDown - Whether to look down for other positions.
Returns:
The next selectable position starting at position and then searching either up or down. Returns AdapterView.INVALID_POSITION if nothing can be found.

setSelectionAfterHeaderView

public void setSelectionAfterHeaderView()
setSelectionAfterHeaderView set the selection to be the first list item after the header views.


dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)
Description copied from class: ViewGroup
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.

Overrides:
dispatchKeyEvent in class ViewGroup
Parameters:
event - The key event to be dispatched.
Returns:
True if the event was handled, false otherwise.

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released, if the view is enabled and clickable.

Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class View
Parameters:
keyCode - A key code that represents the button pressed, from KeyEvent.
event - The KeyEvent object that defines the button action.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyMultiple

public boolean onKeyMultiple(int keyCode,
                             int repeatCount,
                             KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event).

Specified by:
onKeyMultiple in interface KeyEvent.Callback
Overrides:
onKeyMultiple in class View
Parameters:
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.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

onKeyUp

public boolean onKeyUp(int keyCode,
                       KeyEvent event)
Description copied from class: View
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KeyEvent.KEYCODE_DPAD_CENTER or KeyEvent.KEYCODE_ENTER is released.

Specified by:
onKeyUp in interface KeyEvent.Callback
Overrides:
onKeyUp in class AbsListView
Parameters:
keyCode - A key code that represents the button pressed, from KeyEvent.
event - The KeyEvent object that defines the button action.
Returns:
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.

pageScroll

boolean pageScroll(int direction)
Scrolls up or down by the number of items currently present on screen.

Parameters:
direction - either View.FOCUS_UP or View.FOCUS_DOWN
Returns:
whether selection was moved

fullScroll

boolean fullScroll(int direction)
Go to the last or first item if possible (not worrying about panning across or navigating within the internal focus of the currently selected item.)

Parameters:
direction - either View.FOCUS_UP or View.FOCUS_DOWN
Returns:
whether selection was moved

arrowScroll

boolean arrowScroll(int direction)
Scrolls to the next or previous item if possible.

Parameters:
direction - either View.FOCUS_UP or View.FOCUS_DOWN
Returns:
whether selection was moved

setItemsCanFocus

public void setItemsCanFocus(boolean itemsCanFocus)
Indicates that the views created by the ListAdapter can contain focusable items.

Parameters:
itemsCanFocus - true if items can get focus, false otherwise

getItemsCanFocus

public boolean getItemsCanFocus()
Returns:
Whether the views created by the ListAdapter can contain focusable items.

dispatchDraw

protected void dispatchDraw(Canvas canvas)
Description copied from class: ViewGroup
Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Overrides:
dispatchDraw in class AbsListView
Parameters:
canvas - the canvas on which to draw the view

drawDivider

void drawDivider(Canvas canvas,
                 Rect bounds,
                 int childIndex)
Draws a divider for the given child in the given bounds.

Parameters:
canvas - The canvas to draw to.
bounds - The bounds of the divider.
childIndex - The index of child (of the View) above the divider. This will be -1 if there is no child above the divider to be drawn.

getDivider

public Drawable getDivider()
Returns the drawable that will be drawn between each item in the list.

Returns:
the current drawable drawn between list elements

setDivider

public void setDivider(Drawable divider)
Sets the drawable that will be drawn between each item in the list. If the drawable does not have an intrinsic height, you should also call setDividerHeight(int)

Parameters:
divider - The drawable to use.

getDividerHeight

public int getDividerHeight()
Returns:
Returns the height of the divider that will be drawn between each item in the list.

setDividerHeight

public void setDividerHeight(int height)
Sets the height of the divider that will be drawn between each item in the list. Calling this will override the intrinsic height as set by setDivider(Drawable)

Parameters:
height - The new height of the divider in pixels.

onFocusChanged

protected void onFocusChanged(boolean gainFocus,
                              int direction,
                              Rect previouslyFocusedRect)
Description copied from class: View
Called by the view system when the focus state of this view changes. When the focus change event is caused by directional navigation, direction and previouslyFocusedRect provide insight into where the focus is coming from.

Overrides:
onFocusChanged in class AbsListView
Parameters:
gainFocus - True if the View has focus; false otherwise.
direction - The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. It may not always apply, in which case use the default.
previouslyFocusedRect - The rectangle, in this view's coordinate system, of the previously focused view. If applicable, this will be passed in as finer grained information about where the focus is coming from (in addition to direction). Will be null otherwise.

onFinishInflate

protected void onFinishInflate()
Description copied from class: View
Finalize inflating a view from XML. This is called as the last phase of inflation, after all child views have been added.

Even if the subclass overrides onFinishInflate, they should always be sure to call the super method, so that we get called.

Overrides:
onFinishInflate in class View

findViewTraversal

protected View findViewTraversal(int id)
Description copied from class: ViewGroup

Overrides:
findViewTraversal in class ViewGroup
Parameters:
id - the id of the view to be found
Returns:
the view of the specified id, null if cannot be found

findViewInHeadersOrFooters

View findViewInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
                                int id)

findViewWithTagTraversal

protected View findViewWithTagTraversal(Object tag)
Description copied from class: ViewGroup

Overrides:
findViewWithTagTraversal in class ViewGroup
Parameters:
tag - the tag of the view to be found
Returns:
the view of specified tag, null if cannot be found

findViewTagInHeadersOrFooters

View findViewTagInHeadersOrFooters(ArrayList<ListView.FixedViewInfo> where,
                                   Object tag)

onTouchEvent

public boolean onTouchEvent(MotionEvent ev)
Description copied from class: View
Implement this method to handle touch screen motion events.

Overrides:
onTouchEvent in class AbsListView
Parameters:
ev - The motion event.
Returns:
True if the event was handled, false otherwise.

getChoiceMode

public int getChoiceMode()
Returns:
The current choice mode
See Also:
setChoiceMode(int)

setChoiceMode

public void setChoiceMode(int choiceMode)
Defines the choice behavior for the List. By default, Lists do not have any choice behavior (CHOICE_MODE_NONE). By setting the choiceMode to CHOICE_MODE_SINGLE, the List allows up to one item to be in a chosen state. By setting the choiceMode to CHOICE_MODE_MULTIPLE, the list allows any number of items to be chosen.

Parameters:
choiceMode - One of CHOICE_MODE_NONE, CHOICE_MODE_SINGLE, or CHOICE_MODE_MULTIPLE

performItemClick

public boolean performItemClick(View view,
                                int position,
                                long id)
Description copied from class: AdapterView
Call the OnItemClickListener, if it is defined.

Overrides:
performItemClick in class AdapterView<ListAdapter>
Parameters:
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.
Returns:
True if there was an assigned OnItemClickListener that was called, false otherwise is returned.

setItemChecked

public void setItemChecked(int position,
                           boolean value)
Sets the checked state of the specified position. The is only valid if the choice mode has been set to CHOICE_MODE_SINGLE or CHOICE_MODE_MULTIPLE.

Parameters:
position - The item whose checked state is to be checked
value - The new checked sate for the item

isItemChecked

public boolean isItemChecked(int position)
Returns the checked state of the specified position. The result is only valid if the choice mode has not been set to CHOICE_MODE_SINGLE or CHOICE_MODE_MULTIPLE.

Parameters:
position - The item whose checked state to return
Returns:
The item's checked state
See Also:
setChoiceMode(int)

getCheckedItemPosition

public int getCheckedItemPosition()
Returns the currently checked item. The result is only valid if the choice mode has not been set to CHOICE_MODE_SINGLE.

Returns:
The position of the currently checked item or AdapterView.INVALID_POSITION if nothing is selected
See Also:
setChoiceMode(int)

getCheckedItemPositions

public SparseBooleanArray getCheckedItemPositions()
Returns the set of checked items in the list. The result is only valid if the choice mode has not been set to CHOICE_MODE_SINGLE.

Returns:
A SparseBooleanArray which will return true for each call to get(int position) where position is a position in the list.

clearChoices

public void clearChoices()
Clear any choices previously set


onSaveInstanceState

public Parcelable onSaveInstanceState()
Description copied from class: View
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.

Overrides:
onSaveInstanceState in class AbsListView
Returns:
Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save. The default implementation returns null.
See Also:
View.onRestoreInstanceState(android.os.Parcelable), View.saveHierarchyState(android.util.SparseArray), View.dispatchSaveInstanceState(android.util.SparseArray), View.setSaveEnabled(boolean)

onRestoreInstanceState

public void onRestoreInstanceState(Parcelable state)
Description copied from class: View
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by View.onSaveInstanceState(). This function will never be called with a null state.

Overrides:
onRestoreInstanceState in class AbsListView
Parameters:
state - The frozen state that had previously been returned by View.onSaveInstanceState().
See Also:
View.onSaveInstanceState(), View.restoreHierarchyState(android.util.SparseArray), View.dispatchRestoreInstanceState(android.util.SparseArray)

Build 1.0_r1(from source)

Please submit a feedback, bug or feature