java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AdapterView<T extends android.widget.Adapter>
         ↳ android.widget.AbsListView
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Base class that can be used to implement virtualized lists of items. A list does not have a spatial definition here. For instance, subclases of this class can display the content of the list in a grid, in a carousel, as stack, etc.

Summary

Nested Classes
class AbsListView.LayoutParams AbsListView extends LayoutParams to provide a place to hold the view type. 
interface AbsListView.MultiChoiceModeListener A MultiChoiceModeListener receives events for CHOICE_MODE_MULTIPLE_MODAL
interface AbsListView.OnScrollListener Interface definition for a callback to be invoked when the list or grid has been scrolled. 
interface AbsListView.RecyclerListener A RecyclerListener is used to receive a notification whenever a View is placed inside the RecycleBin's scrap heap. 
interface AbsListView.SelectionBoundsAdjuster The top-level view of a list item can implement this interface to allow itself to modify the bounds of the selection shown for that item. 
XML Attributes
Attribute Name Related Method Description
android:cacheColorHint Indicates that this list will always be drawn on top of solid, single-color opaque background. 
android:choiceMode Defines the choice behavior for the view. 
android:drawSelectorOnTop setDrawSelectorOnTop(boolean) When set to true, the selector will be drawn over the selected item. 
android:fastScrollEnabled Enables the fast scroll thumb that can be dragged to quickly scroll through the list. 
android:listSelector setSelector(int) Drawable used to indicate the currently selected item in the list. 
android:scrollingCache When set to true, the list uses a drawing cache during scrolling. 
android:smoothScrollbar setSmoothScrollbarEnabled(boolean) When set to true, the list will use a more refined calculation method based on the pixels height of the items visible on screen. 
android:stackFromBottom Used by ListView and GridView to stack their content from the bottom. 
android:textFilterEnabled When set to true, the list will filter results as the user types. 
android:transcriptMode Sets the transcript mode for the list. 
[Expand]
Inherited XML Attributes
From class android.view.ViewGroup
From class android.view.View
Constants
int CHOICE_MODE_MULTIPLE The list allows multiple choices
int CHOICE_MODE_MULTIPLE_MODAL The list allows multiple choices in a modal selection mode
int CHOICE_MODE_NONE Normal list that does not indicate choices
int CHOICE_MODE_SINGLE The list allows up to one choice
int TRANSCRIPT_MODE_ALWAYS_SCROLL The list will automatically scroll to the bottom, no matter what items are currently visible.
int TRANSCRIPT_MODE_DISABLED Disables the transcript mode.
int TRANSCRIPT_MODE_NORMAL The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen.
[Expand]
Inherited Constants
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
AbsListView(Context context)
AbsListView(Context context, AttributeSet attrs)
AbsListView(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addTouchables(ArrayList<View> views)
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
void afterTextChanged(Editable s)
For our text watcher that is associated with the text filter.
void beforeTextChanged(CharSequence s, int start, int count, int after)
For our text watcher that is associated with the text filter.
boolean checkInputConnectionProxy(View view)
For filtering we proxy an input connection to an internal text editor, and this allows the proxying to happen.
void clearChoices()
Clear any choices previously set
void clearTextFilter()
Clear the text filter.
void draw(Canvas canvas)
Manually render this view (and all of its children) to the given Canvas.
AbsListView.LayoutParams generateLayoutParams(AttributeSet attrs)
Returns a new set of layout parameters based on the supplied attributes set.
int getCacheColorHint()
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
int getCheckedItemCount()
Returns the number of items currently selected.
long[] getCheckedItemIds()
Returns the set of checked items ids.
int getCheckedItemPosition()
Returns the currently checked item.
SparseBooleanArray getCheckedItemPositions()
Returns the set of checked items in the list.
int getChoiceMode()
void getFocusedRect(Rect r)
When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method.
int getListPaddingBottom()
List padding is the maximum of the normal view's padding and the padding of the selector.
int getListPaddingLeft()
List padding is the maximum of the normal view's padding and the padding of the selector.
int getListPaddingRight()
List padding is the maximum of the normal view's padding and the padding of the selector.
int getListPaddingTop()
List padding is the maximum of the normal view's padding and the padding of the selector.
View getSelectedView()
Drawable getSelector()
Returns the selector Drawable that is used to draw the selection in the list.
int getSolidColor()
Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges.
CharSequence getTextFilter()
Returns the list's text filter, if available.
int getTranscriptMode()
Returns the current transcript mode.
int getVerticalScrollbarWidth()
Returns the width of the vertical scrollbar.
boolean hasTextFilter()
Returns if the ListView currently has a text filter.
void invalidateViews()
Causes all the views to be rebuilt and redrawn.
boolean isFastScrollAlwaysVisible()
Returns true if the fast scroller is set to always show on this view rather than fade out when not in use.
boolean isFastScrollEnabled()
Returns the current state of the fast scroll feature.
boolean isItemChecked(int position)
Returns the checked state of the specified position.
boolean isScrollingCacheEnabled()
Indicates whether the children's drawing cache is used during a scroll.
boolean isSmoothScrollbarEnabled()
Returns the current state of the fast scroll feature.
boolean isStackFromBottom()
Indicates whether the content of this view is pinned to, or stacked from, the bottom edge.
boolean isTextFilterEnabled()
Indicates whether type filtering is enabled for this view
void jumpDrawablesToCurrentState()
Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.
InputConnection onCreateInputConnection(EditorInfo outAttrs)
Return an InputConnection for editing of the filter text.
void onFilterComplete(int count)

Notifies the end of a filtering operation.

void onGlobalLayout()
Callback method to be invoked when the global layout state or the visibility of views within the view tree changes
boolean onInterceptTouchEvent(MotionEvent ev)
Implement this method to intercept all touch screen motion events.
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 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 onRemoteAdapterConnected()
Called back when the adapter connects to the RemoteViewsService.
void onRemoteAdapterDisconnected()
Called back when the adapter disconnects from the RemoteViewsService.
void onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously been generated by 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.
void onTextChanged(CharSequence s, int start, int before, int count)
For our text watcher that is associated with the text filter.
boolean onTouchEvent(MotionEvent ev)
Implement this method to handle touch screen motion events.
void onTouchModeChanged(boolean isInTouchMode)
Callback method to be invoked when the touch mode changes.
void onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing this view gains or loses focus.
boolean performItemClick(View view, int position, long id)
Call the OnItemClickListener, if it is defined.
int pointToPosition(int x, int y)
Maps a point to a position in the list.
long pointToRowId(int x, int y)
Maps a point to a the rowId of the item which intersects that point.
void reclaimViews(List<View> views)
Move all views (excluding headers and footers) held by this AbsListView into the supplied List.
void requestLayout()
Call this when something has changed which has invalidated the layout of this view.
void setAdapter(ListAdapter adapter)
Sets the adapter that provides the data and the views to represent the data in this widget.
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 setChoiceMode(int choiceMode)
Defines the choice behavior for the List.
void setDrawSelectorOnTop(boolean onTop)
Controls whether the selection highlight drawable should be drawn on top of the item or behind it.
void setFastScrollAlwaysVisible(boolean alwaysShow)
Set whether or not the fast scroller should always be shown in place of the standard scrollbars.
void setFastScrollEnabled(boolean enabled)
Enables fast scrolling by letting the user quickly scroll through lists by dragging the fast scroll thumb.
void setFilterText(String filterText)
Sets the initial value for the text filter.
void setFriction(float friction)
The amount of friction applied to flings.
void setItemChecked(int position, boolean value)
Sets the checked state of the specified position.
void setMultiChoiceModeListener(AbsListView.MultiChoiceModeListener listener)
Set a AbsListView.MultiChoiceModeListener that will manage the lifecycle of the selection ActionMode.
void setOnScrollListener(AbsListView.OnScrollListener l)
Set the listener that will receive notifications every time the list scrolls.
void setOverScrollMode(int mode)
Set the over-scroll mode for this view.
void setRecyclerListener(AbsListView.RecyclerListener listener)
Sets the recycler listener to be notified whenever a View is set aside in the recycler for later reuse.
void setRemoteViewsAdapter(Intent intent)
Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService through the specified intent.
void setScrollIndicators(View up, View down)
void setScrollingCacheEnabled(boolean enabled)
Enables or disables the children's drawing cache during a scroll.
void setSelector(Drawable sel)
void setSelector(int resID)
Set a Drawable that should be used to highlight the currently selected item.
void setSmoothScrollbarEnabled(boolean enabled)
When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed based on the number of visible pixels in the visible items.
void setStackFromBottom(boolean stackFromBottom)
When stack from bottom is set to true, the list fills its content starting from the bottom of the view.
void setTextFilterEnabled(boolean textFilterEnabled)
Enables or disables the type filter window.
void setTranscriptMode(int mode)
Puts the list or grid into transcript mode.
void setVelocityScale(float scale)
Sets a scale factor for the fling velocity.
void setVerticalScrollbarPosition(int position)
Set the position of the vertical scroll bar.
boolean showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors.
void smoothScrollBy(int distance, int duration)
Smoothly scroll by distance pixels over duration milliseconds.
void smoothScrollToPosition(int position)
Smoothly scroll to the specified adapter position.
void smoothScrollToPosition(int position, int boundPosition)
Smoothly scroll to the specified adapter position.
void smoothScrollToPositionFromTop(int position, int offset, int duration)
Smoothly scroll to the specified adapter position.
void smoothScrollToPositionFromTop(int position, int offset)
Smoothly scroll to the specified adapter position.
boolean verifyDrawable(Drawable dr)
If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.
Protected Methods
boolean checkLayoutParams(ViewGroup.LayoutParams p)
int computeVerticalScrollExtent()

Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range.

int computeVerticalScrollOffset()

Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range.

int computeVerticalScrollRange()

Compute the vertical range that the vertical scrollbar represents.

void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
void dispatchSetPressed(boolean pressed)
Dispatch setPressed to all of this View's children.
void drawableStateChanged()
This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.
ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
Returns a safe set of layout parameters based on the supplied layout params.
float getBottomFadingEdgeStrength()
Returns the strength, or intensity, of the bottom faded edge.
int getBottomPaddingOffset()
Amount by which to extend the bottom fading region.
ContextMenu.ContextMenuInfo getContextMenuInfo()
Views should implement this if they have extra information to associate with the context menu.
int getLeftPaddingOffset()
Amount by which to extend the left fading region.
int getRightPaddingOffset()
Amount by which to extend the right fading region.
float getTopFadingEdgeStrength()
Returns the strength, or intensity, of the top faded edge.
int getTopPaddingOffset()
Amount by which to extend the top fading region.
void handleDataChanged()
boolean isInFilterMode()
Indicates whether this view is in filter mode.
boolean isPaddingOffsetRequired()
If the View draws content inside its padding and enables fading edges, it needs to support padding offsets.
void layoutChildren()
Subclasses must override this method to layout their children.
void onAttachedToWindow()
This is called when the view is attached to a window.
int[] onCreateDrawableState(int extraSpace)
Generate the new Drawable state for this view.
void onDetachedFromWindow()
This is called when the view is detached from a window.
void onDisplayHint(int hint)
Gives this view a hint about whether is displayed or not.
void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
Called by the view system when the focus state of this view changes.
void onLayout(boolean changed, int l, int t, int r, int b)
Subclasses should NOT override this method but layoutChildren() instead.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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

void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY)
Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to respond to the results of an over-scroll operation.
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.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

XML Attributes

android:cacheColorHint

Since: API Level

Indicates that this list will always be drawn on top of solid, single-color opaque background. This allows the list to optimize drawing.

Must be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".

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 cacheColorHint.

Related Methods

android:choiceMode

Since: API Level

Defines the choice behavior for the view. 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. Finally, by setting the choiceMode to multipleChoiceModal the list allows any number of items to be chosen in a special selection mode. The application will supply a AbsListView.MultiChoiceModeListener using setMultiChoiceModeListener(AbsListView.MultiChoiceModeListener) to control the selection mode. This uses the ActionMode API.

Must be one of the following constant values.

ConstantValueDescription
none0 Normal list that does not indicate choices.
singleChoice1 The list allows up to one choice.
multipleChoice2 The list allows multiple choices.
multipleChoiceModal3 The list allows multiple choices in a custom selection mode.

This corresponds to the global attribute resource symbol choiceMode.

Related Methods

android:drawSelectorOnTop

Since: API Level

When set to true, the selector will be drawn over the selected item. Otherwise the selector is drawn behind the selected item. The default value is false.

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 drawSelectorOnTop.

android:fastScrollEnabled

Since: API Level

Enables the fast scroll thumb that can be dragged to quickly scroll through the list.

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 fastScrollEnabled.

Related Methods

android:listSelector

Since: API Level

Drawable used to indicate the currently selected item in the list.

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 listSelector.

Related Methods

android:scrollingCache

Since: API Level

When set to true, the list uses a drawing cache during scrolling. This makes the rendering faster but uses more memory. 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 scrollingCache.

Related Methods

android:smoothScrollbar

Since: API Level

When set to true, the list will use a more refined calculation method based on the pixels height of the items visible on screen. This property is set to true by default but should be set to false if your adapter will display items of varying heights. When this property is set to true and your adapter displays items of varying heights, the scrollbar thumb will change size as the user scrolls through the list. When set to fale, the list will use only the number of items in the adapter and the number of items visible on screen to determine the scrollbar's properties.

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 smoothScrollbar.

android:stackFromBottom

Since: API Level

Used by ListView and GridView to stack their content from the bottom.

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 stackFromBottom.

Related Methods

android:textFilterEnabled

Since: API Level

When set to true, the list will filter results as the user types. The List's adapter must support the Filterable interface for this to work.

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 textFilterEnabled.

Related Methods

android:transcriptMode

Since: API Level

Sets the transcript mode for the list. In transcript mode, the list scrolls to the bottom to make new items visible when they are added.

Must be one of the following constant values.

ConstantValueDescription
disabled0 Disables transcript mode. This is the default value.
normal1 The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen.
alwaysScroll2 The list will automatically scroll to the bottom, no matter what items are currently visible.

This corresponds to the global attribute resource symbol transcriptMode.

Related Methods

Constants

public static final int CHOICE_MODE_MULTIPLE

Since: API Level 1

The list allows multiple choices

Constant Value: 2 (0x00000002)

public static final int CHOICE_MODE_MULTIPLE_MODAL

Since: API Level 11

The list allows multiple choices in a modal selection mode

Constant Value: 3 (0x00000003)

public static final int CHOICE_MODE_NONE

Since: API Level 1

Normal list that does not indicate choices

Constant Value: 0 (0x00000000)

public static final int CHOICE_MODE_SINGLE

Since: API Level 1

The list allows up to one choice

Constant Value: 1 (0x00000001)

public static final int TRANSCRIPT_MODE_ALWAYS_SCROLL

Since: API Level 1

The list will automatically scroll to the bottom, no matter what items are currently visible.

Constant Value: 2 (0x00000002)

public static final int TRANSCRIPT_MODE_DISABLED

Since: API Level 1

Disables the transcript mode.

Constant Value: 0 (0x00000000)

public static final int TRANSCRIPT_MODE_NORMAL

Since: API Level 1

The list will automatically scroll to the bottom when a data set change notification is received and only if the last item is already visible on screen.

Constant Value: 1 (0x00000001)

Public Constructors

public AbsListView (Context context)

Since: API Level 1

public AbsListView (Context context, AttributeSet attrs)

Since: API Level 1

public AbsListView (Context context, AttributeSet attrs, int defStyle)

Since: API Level 1

Public Methods

public void addTouchables (ArrayList<View> views)

Since: API Level 1

Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.

Parameters
views Touchable views found so far

public void afterTextChanged (Editable s)

Since: API Level 1

For our text watcher that is associated with the text filter. Does nothing.

public void beforeTextChanged (CharSequence s, int start, int count, int after)

Since: API Level 1

For our text watcher that is associated with the text filter. Does nothing.

public boolean checkInputConnectionProxy (View view)

Since: API Level 3

For filtering we proxy an input connection to an internal text editor, and this allows the proxying to happen.

Parameters
view The View that is making the InputMethodManager call.
Returns
  • Return true to allow the call, false to reject.

public void clearChoices ()

Since: API Level 1

Clear any choices previously set

public void clearTextFilter ()

Since: API Level 1

Clear the text filter.

public void draw (Canvas canvas)

Since: API Level 1

Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement onDraw(Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.

Parameters
canvas The Canvas to which the View is rendered.

public AbsListView.LayoutParams generateLayoutParams (AttributeSet attrs)

Since: API Level 1

Returns a new set of layout parameters based on the supplied attributes set.

Parameters
attrs the attributes to build the layout parameters from
Returns

public int getCacheColorHint ()

Since: API Level 1

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

Returns
  • The cache color hint

public int getCheckedItemCount ()

Since: API Level 11

Returns the number of items currently selected. This will only be valid if the choice mode is not CHOICE_MODE_NONE (default).

To determine the specific items that are currently selected, use one of the getChecked* methods.

Returns
  • The number of items currently selected

public long[] getCheckedItemIds ()

Since: API Level 8

Returns the set of checked items ids. The result is only valid if the choice mode has not been set to CHOICE_MODE_NONE and the adapter has stable IDs. (hasStableIds() == true)

Returns
  • A new array which contains the id of each checked item in the list.

public int getCheckedItemPosition ()

Since: API Level 1

Returns the currently checked item. The result is only valid if the choice mode has been set to CHOICE_MODE_SINGLE.

Returns
  • The position of the currently checked item or INVALID_POSITION if nothing is selected

public SparseBooleanArray getCheckedItemPositions ()

Since: API Level 1

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_NONE.

Returns
  • A SparseBooleanArray which will return true for each call to get(int position) where position is a position in the list, or null if the choice mode is set to CHOICE_MODE_NONE.

public int getChoiceMode ()

Since: API Level 1

Returns
  • The current choice mode

public void getFocusedRect (Rect r)

Since: API Level 1

When a view has focus and the user navigates away from it, the next view is searched for starting from the rectangle filled in by this method. By default, the rectange is the getDrawingRect(Rect))of the view. However, if your view maintains some idea of internal selection, such as a cursor, or a selected row or column, you should override this method and fill in a more specific rectangle.

Parameters
r The rectangle to fill in, in this view's coordinates.

public int getListPaddingBottom ()

Since: API Level 1

List padding is the maximum of the normal view's padding and the padding of the selector.

Returns
  • The bottom list padding.

public int getListPaddingLeft ()

Since: API Level 1

List padding is the maximum of the normal view's padding and the padding of the selector.

Returns
  • The left list padding.

public int getListPaddingRight ()

Since: API Level 1

List padding is the maximum of the normal view's padding and the padding of the selector.

Returns
  • The right list padding.

public int getListPaddingTop ()

Since: API Level 1

List padding is the maximum of the normal view's padding and the padding of the selector.

Returns
  • The top list padding.

public View getSelectedView ()

Since: API Level 1

Returns
  • The view corresponding to the currently selected item, or null if nothing is selected

public Drawable getSelector ()

Since: API Level 1

Returns the selector Drawable that is used to draw the selection in the list.

Returns
  • the drawable used to display the selector

public int getSolidColor ()

Since: API Level 1

Override this if your view is known to always be drawn on top of a solid color background, and needs to draw fading edges. Returning a non-zero color enables the view system to optimize the drawing of the fading edges. If you do return a non-zero color, the alpha should be set to 0xFF.

Returns
  • The known solid color background for this view, or 0 if the color may vary

public CharSequence getTextFilter ()

Since: API Level 3

Returns the list's text filter, if available.

Returns
  • the list's text filter or null if filtering isn't enabled

public int getTranscriptMode ()

Since: API Level 1

Returns the current transcript mode.

public int getVerticalScrollbarWidth ()

Since: API Level 1

Returns the width of the vertical scrollbar.

Returns
  • The width in pixels of the vertical scrollbar or 0 if there is no vertical scrollbar.

public boolean hasTextFilter ()

Since: API Level 1

Returns if the ListView currently has a text filter.

public void invalidateViews ()

Since: API Level 1

Causes all the views to be rebuilt and redrawn.

public boolean isFastScrollAlwaysVisible ()

Since: API Level 11

Returns true if the fast scroller is set to always show on this view rather than fade out when not in use.

Returns
  • true if the fast scroller will always show.

public boolean isFastScrollEnabled ()

Since: API Level 3

Returns the current state of the fast scroll feature.

Returns
  • true if fast scroll is enabled, false otherwise

public boolean isItemChecked (int position)

Since: API Level 1

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.

Parameters
position The item whose checked state to return
Returns
  • The item's checked state or false if choice mode is invalid

public boolean isScrollingCacheEnabled ()

Since: API Level 1

Indicates whether the children's drawing cache is used during a scroll. By default, the drawing cache is enabled but this will consume more memory.

Returns
  • true if the scrolling cache is enabled, false otherwise

public boolean isSmoothScrollbarEnabled ()

Since: API Level 3

Returns the current state of the fast scroll feature.

Returns
  • True if smooth scrollbar is enabled is enabled, false otherwise.

public boolean isStackFromBottom ()

Since: API Level 1

Indicates whether the content of this view is pinned to, or stacked from, the bottom edge.

Returns
  • true if the content is stacked from the bottom edge, false otherwise

public boolean isTextFilterEnabled ()

Since: API Level 1

Indicates whether type filtering is enabled for this view

Returns
  • true if type filtering is enabled, false otherwise

public void jumpDrawablesToCurrentState ()

Since: API Level 11

Call Drawable.jumpToCurrentState() on all Drawable objects associated with this view.

public InputConnection onCreateInputConnection (EditorInfo outAttrs)

Since: API Level 3

Return an InputConnection for editing of the filter text.

Parameters
outAttrs Fill in with attribute information about the connection.

public void onFilterComplete (int count)

Since: API Level 1

Notifies the end of a filtering operation.

Parameters
count the number of values computed by the filter

public void onGlobalLayout ()

Since: API Level 1

Callback method to be invoked when the global layout state or the visibility of views within the view tree changes

public boolean onInterceptTouchEvent (MotionEvent ev)

Since: API Level 1

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

Parameters
ev The motion event being dispatched down the hierarchy.
Returns
  • Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

public boolean onKeyDown (int keyCode, KeyEvent event)

Since: API Level 1

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.

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.

public boolean onKeyUp (int keyCode, KeyEvent event)

Since: API Level 1

Default implementation of KeyEvent.Callback.onKeyUp(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released.

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.

public boolean onRemoteAdapterConnected ()

Since: API Level 11

Called back when the adapter connects to the RemoteViewsService.

public void onRemoteAdapterDisconnected ()

Since: API Level 11

Called back when the adapter disconnects from the RemoteViewsService.

public void onRestoreInstanceState (Parcelable state)

Since: API Level 1

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.

Parameters
state The frozen state that had previously been returned by onSaveInstanceState().

public Parcelable onSaveInstanceState ()

Since: API Level 1

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.

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.

public void onTextChanged (CharSequence s, int start, int before, int count)

Since: API Level 1

For our text watcher that is associated with the text filter. Performs the actual filtering as the text changes, and takes care of hiding and showing the popup displaying the currently entered filter text.

public boolean onTouchEvent (MotionEvent ev)

Since: API Level 1

Implement this method to handle touch screen motion events.

Parameters
ev The motion event.
Returns
  • True if the event was handled, false otherwise.

public void onTouchModeChanged (boolean isInTouchMode)

Since: API Level 1

Callback method to be invoked when the touch mode changes.

Parameters
isInTouchMode True if the view hierarchy is now in touch mode, false otherwise.

public void onWindowFocusChanged (boolean hasWindowFocus)

Since: API Level 1

Called when the window containing this view gains or loses focus. Note that this is separate from view focus: to receive key events, both your view and its window must have focus. If a window is displayed on top of yours that takes input focus, then your own window will lose focus but the view focus will remain unchanged.

Parameters
hasWindowFocus True if the window containing this view now has focus, false otherwise.

public boolean performItemClick (View view, int position, long id)

Since: API Level 1

Call the OnItemClickListener, if it is defined.

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.

public int pointToPosition (int x, int y)

Since: API Level 1

Maps a point to a position in the list.

Parameters
x X in local coordinate
y Y in local coordinate
Returns
  • The position of the item which contains the specified point, or INVALID_POSITION if the point does not intersect an item.

public long pointToRowId (int x, int y)

Since: API Level 1

Maps a point to a the rowId of the item which intersects that point.

Parameters
x X in local coordinate
y Y in local coordinate
Returns
  • The rowId of the item which contains the specified point, or INVALID_ROW_ID if the point does not intersect an item.

public void reclaimViews (List<View> views)

Since: API Level 1

Move all views (excluding headers and footers) held by this AbsListView into the supplied List. This includes views displayed on the screen as well as views stored in AbsListView's internal view recycler.

Parameters
views A list into which to put the reclaimed views

public void requestLayout ()

Since: API Level 1

Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree.

public void setAdapter (ListAdapter adapter)

Since: API Level 11

Sets the adapter that provides the data and the views to represent the data in this widget.

Parameters
adapter The adapter to use to create this view's content.

public void setCacheColorHint (int color)

Since: API Level 1

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. Zero means that what's behind this object is translucent (non solid) or is not made of a single color. This hint will not affect any existing background drawable set on this view ( typically set via setBackgroundDrawable(Drawable)).

Parameters
color The background color

public void setChoiceMode (int choiceMode)

Since: API Level 1

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

public void setDrawSelectorOnTop (boolean onTop)

Since: API Level 1

Controls whether the selection highlight drawable should be drawn on top of the item or behind it.

Related XML Attributes
Parameters
onTop If true, the selector will be drawn on the item it is highlighting. The default is false.

public void setFastScrollAlwaysVisible (boolean alwaysShow)

Since: API Level 11

Set whether or not the fast scroller should always be shown in place of the standard scrollbars. Fast scrollers shown in this way will not fade out and will be a permanent fixture within the list. Best combined with an inset scroll bar style that will ensure enough padding. This will enable fast scrolling if it is not already enabled.

Parameters
alwaysShow true if the fast scroller should always be displayed.

public void setFastScrollEnabled (boolean enabled)

Since: API Level 3

Enables fast scrolling by letting the user quickly scroll through lists by dragging the fast scroll thumb. The adapter attached to the list may want to implement SectionIndexer if it wishes to display alphabet preview and jump between sections of the list.

Parameters
enabled whether or not to enable fast scrolling

public void setFilterText (String filterText)

Since: API Level 1

Sets the initial value for the text filter.

Parameters
filterText The text to use for the filter.

public void setFriction (float friction)

Since: API Level 11

The amount of friction applied to flings. The default value is getScrollFriction().

Returns
  • A scalar dimensionless value representing the coefficient of friction.

public void setItemChecked (int position, boolean value)

Since: API Level 1

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 state for the item

public void setMultiChoiceModeListener (AbsListView.MultiChoiceModeListener listener)

Since: API Level 11

Set a AbsListView.MultiChoiceModeListener that will manage the lifecycle of the selection ActionMode. Only used when the choice mode is set to CHOICE_MODE_MULTIPLE_MODAL.

Parameters
listener Listener that will manage the selection mode

public void setOnScrollListener (AbsListView.OnScrollListener l)

Since: API Level 1

Set the listener that will receive notifications every time the list scrolls.

Parameters
l the scroll listener

public void setOverScrollMode (int mode)

Since: API Level 9

Set the over-scroll mode for this view. Valid over-scroll modes are OVER_SCROLL_ALWAYS (default), OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER. Setting the over-scroll mode of a view will have an effect only if the view is capable of scrolling.

Parameters
mode The new over-scroll mode for this view.

public void setRecyclerListener (AbsListView.RecyclerListener listener)

Since: API Level 1

Sets the recycler listener to be notified whenever a View is set aside in the recycler for later reuse. This listener can be used to free resources associated to the View.

Parameters
listener The recycler listener to be notified of views set aside in the recycler.
See Also

public void setRemoteViewsAdapter (Intent intent)

Since: API Level 11

Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService through the specified intent.

Parameters
intent the intent used to identify the RemoteViewsService for the adapter to connect to.

public void setScrollIndicators (View up, View down)

Since: API Level 1

public void setScrollingCacheEnabled (boolean enabled)

Since: API Level 1

Enables or disables the children's drawing cache during a scroll. By default, the drawing cache is enabled but this will use more memory. When the scrolling cache is enabled, the caches are kept after the first scrolling. You can manually clear the cache by calling setChildrenDrawingCacheEnabled(boolean).

Parameters
enabled true to enable the scroll cache, false otherwise

public void setSelector (Drawable sel)

Since: API Level 1

public void setSelector (int resID)

Since: API Level 1

Set a Drawable that should be used to highlight the currently selected item.

Related XML Attributes
Parameters
resID A Drawable resource to use as the selection highlight.

public void setSmoothScrollbarEnabled (boolean enabled)

Since: API Level 3

When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed based on the number of visible pixels in the visible items. This however assumes that all list items have the same height. If you use a list in which items have different heights, the scrollbar will change appearance as the user scrolls through the list. To avoid this issue, you need to disable this property. When smooth scrollbar is disabled, the position and size of the scrollbar thumb is based solely on the number of items in the adapter and the position of the visible items inside the adapter. This provides a stable scrollbar as the user navigates through a list of items with varying heights.

Related XML Attributes
Parameters
enabled Whether or not to enable smooth scrollbar.

public void setStackFromBottom (boolean stackFromBottom)

Since: API Level 1

When stack from bottom is set to true, the list fills its content starting from the bottom of the view.

Parameters
stackFromBottom true to pin the view's content to the bottom edge, false to pin the view's content to the top edge

public void setTextFilterEnabled (boolean textFilterEnabled)

Since: API Level 1

Enables or disables the type filter window. If enabled, typing when this view has focus will filter the children to match the users input. Note that the Adapter used by this view must implement the Filterable interface.

Parameters
textFilterEnabled true to enable type filtering, false otherwise
See Also

public void setTranscriptMode (int mode)

Since: API Level 1

Puts the list or grid into transcript mode. In this mode the list or grid will always scroll to the bottom to show new items.

Parameters
mode the transcript mode to set

public void setVelocityScale (float scale)

Since: API Level 11

Sets a scale factor for the fling velocity. The initial scale factor is 1.0.

Parameters
scale The scale factor to multiply the velocity by.

public void setVerticalScrollbarPosition (int position)

Since: API Level 11

Set the position of the vertical scroll bar. Should be one of SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT or SCROLLBAR_POSITION_RIGHT.

Parameters
position Where the vertical scroll bar should be positioned.

public boolean showContextMenuForChild (View originalView)

Since: API Level 1

Bring up a context menu for the specified view or its ancestors.

In most cases, a subclass does not need to override this. However, if the subclass is added directly to the window manager (for example, addView(View, android.view.ViewGroup.LayoutParams)) then it should override this and show the context menu.

Parameters
originalView The source view where the context menu was first invoked
Returns
  • true if a context menu was displayed

public void smoothScrollBy (int distance, int duration)

Since: API Level 8

Smoothly scroll by distance pixels over duration milliseconds.

Parameters
distance Distance to scroll in pixels.
duration Duration of the scroll animation in milliseconds.

public void smoothScrollToPosition (int position)

Since: API Level 8

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.

Parameters
position Scroll to this adapter position.

public void smoothScrollToPosition (int position, int boundPosition)

Since: API Level 8

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed, but it will stop early if scrolling further would scroll boundPosition out of view.

Parameters
position Scroll to this adapter position.
boundPosition Do not scroll if it would move this adapter position out of view.

public void smoothScrollToPositionFromTop (int position, int offset, int duration)

Since: API Level 11

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed offset pixels from the top edge of the view. If this is impossible, (e.g. the offset would scroll the first or last item beyond the boundaries of the list) it will get as close as possible. The scroll will take duration milliseconds to complete.

Parameters
position Position to scroll to
offset Desired distance in pixels of position from the top of the view when scrolling is finished
duration Number of milliseconds to use for the scroll

public void smoothScrollToPositionFromTop (int position, int offset)

Since: API Level 11

Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed offset pixels from the top edge of the view. If this is impossible, (e.g. the offset would scroll the first or last item beyond the boundaries of the list) it will get as close as possible.

Parameters
position Position to scroll to
offset Desired distance in pixels of position from the top of the view when scrolling is finished

public boolean verifyDrawable (Drawable dr)

Since: API Level 1

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.

Parameters
dr The Drawable to verify. Return true if it is one you are displaying, else return the result of calling through to the super class.
Returns
  • boolean If true than the Drawable is being displayed in the view; else false and it is not allowed to animate.

Protected Methods

protected boolean checkLayoutParams (ViewGroup.LayoutParams p)

Since: API Level 1

protected int computeVerticalScrollExtent ()

Since: API Level 1

Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. This value is used to compute the length of the thumb within the scrollbar's track.

The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollOffset().

The default extent is the drawing height of this view.

Returns
  • the vertical extent of the scrollbar's thumb

protected int computeVerticalScrollOffset ()

Since: API Level 1

Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.

The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollRange() and computeVerticalScrollExtent().

The default offset is the scroll offset of this view.

Returns
  • the vertical offset of the scrollbar's thumb

protected int computeVerticalScrollRange ()

Since: API Level 1

Compute the vertical range that the vertical scrollbar represents.

The range is expressed in arbitrary units that must be the same as the units used by computeVerticalScrollExtent() and computeVerticalScrollOffset().

Returns
  • the total vertical range represented by the vertical scrollbar

    The default range is the drawing height of this view.

protected void dispatchDraw (Canvas canvas)

Since: API Level 1

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).

Parameters
canvas the canvas on which to draw the view

protected void dispatchSetPressed (boolean pressed)

Since: API Level 1

Dispatch setPressed to all of this View's children.

Parameters
pressed The new pressed state

protected void drawableStateChanged ()

Since: API Level 1

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

Be sure to call through to the superclass when overriding this function.

protected ViewGroup.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

Since: API Level 1

Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Parameters
p The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns

protected float getBottomFadingEdgeStrength ()

Since: API Level 1

Returns the strength, or intensity, of the bottom faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.

Returns
  • the intensity of the bottom fade as a float between 0.0f and 1.0f

protected int getBottomPaddingOffset ()

Since: API Level 2

Amount by which to extend the bottom fading region. Called only when isPaddingOffsetRequired() returns true.

Returns
  • The bottom padding offset in pixels.

protected ContextMenu.ContextMenuInfo getContextMenuInfo ()

Since: API Level 1

Views should implement this if they have extra information to associate with the context menu. The return result is supplied as a parameter to the onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback.

Returns
  • Extra information about the item for which the context menu should be shown. This information will vary across different subclasses of View.

protected int getLeftPaddingOffset ()

Since: API Level 2

Amount by which to extend the left fading region. Called only when isPaddingOffsetRequired() returns true.

Returns
  • The left padding offset in pixels.

protected int getRightPaddingOffset ()

Since: API Level 2

Amount by which to extend the right fading region. Called only when isPaddingOffsetRequired() returns true.

Returns
  • The right padding offset in pixels.

protected float getTopFadingEdgeStrength ()

Since: API Level 1

Returns the strength, or intensity, of the top faded edge. The strength is a value between 0.0 (no fade) and 1.0 (full fade). The default implementation returns 0.0 or 1.0 but no value in between. Subclasses should override this method to provide a smoother fade transition when scrolling occurs.

Returns
  • the intensity of the top fade as a float between 0.0f and 1.0f

protected int getTopPaddingOffset ()

Since: API Level 2

Amount by which to extend the top fading region. Called only when isPaddingOffsetRequired() returns true.

Returns
  • The top padding offset in pixels.

protected void handleDataChanged ()

Since: API Level 1

protected boolean isInFilterMode ()

Since: API Level 1

Indicates whether this view is in filter mode. Filter mode can for instance be enabled by a user when typing on the keyboard.

Returns
  • True if the view is in filter mode, false otherwise.

protected boolean isPaddingOffsetRequired ()

Since: API Level 2

If the View draws content inside its padding and enables fading edges, it needs to support padding offsets. Padding offsets are added to the fading edges to extend the length of the fade so that it covers pixels drawn inside the padding. Subclasses of this class should override this method if they need to draw content inside the padding.

Returns
  • True if padding offset must be applied, false otherwise.

protected void layoutChildren ()

Since: API Level 1

Subclasses must override this method to layout their children.

protected void onAttachedToWindow ()

Since: API Level 1

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected int[] onCreateDrawableState (int extraSpace)

Since: API Level 1

Generate the new Drawable state for this view. This is called by the view system when the cached Drawable state is determined to be invalid. To retrieve the current state, you should use getDrawableState().

Parameters
extraSpace if non-zero, this is the number of extra entries you would like in the returned array in which you can place your own states.
Returns
  • Returns an array holding the current Drawable state of the view.

protected void onDetachedFromWindow ()

Since: API Level 1

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

protected void onDisplayHint (int hint)

Since: API Level 8

Gives this view a hint about whether is displayed or not. For instance, when a View moves out of the screen, it might receives a display hint indicating the view is not displayed. Applications should not rely on this hint as there is no guarantee that they will receive one.

Parameters
hint A hint about whether or not this view is displayed: VISIBLE or INVISIBLE.

protected void onFocusChanged (boolean gainFocus, int direction, Rect previouslyFocusedRect)

Since: API Level 1

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. When overriding, be sure to call up through to the super class so that the standard focus handling will occur.

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 FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_FORWARD, or FOCUS_BACKWARD. 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.

protected void onLayout (boolean changed, int l, int t, int r, int b)

Since: API Level 1

Subclasses should NOT override this method but layoutChildren() instead.

Parameters
changed This is a new size or position for this view
l Left position, relative to parent
t Top position, relative to parent
r Right position, relative to parent
b Bottom position, relative to parent

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Since: API Level 1

Measure the view and its content to determine the measured width and the measured height. This method is invoked by 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 setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' 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 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 (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

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.

protected void onOverScrolled (int scrollX, int scrollY, boolean clampedX, boolean clampedY)

Since: API Level 9

Called by overScrollBy(int, int, int, int, int, int, int, int, boolean) to respond to the results of an over-scroll operation.

Parameters
scrollX New X scroll value in pixels
scrollY New Y scroll value in pixels
clampedX True if scrollX was clamped to an over-scroll boundary
clampedY True if scrollY was clamped to an over-scroll boundary

protected void onSizeChanged (int w, int h, int oldw, int oldh)

Since: API Level 1

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w Current width of this view.
h Current height of this view.
oldw Old width of this view.
oldh Old height of this view.