Common code shared between ListView and GridView
AbsListView.LayoutParams | AbsListView extends LayoutParams to provide a place to hold the view type. |
AbsListView.OnScrollListener | Interface definition for a callback to be invoked when the list or grid has been scrolled. |
AbsListView.RecyclerListener | A RecyclerListener is used to receive a notification whenever a View is placed inside the RecycleBin's scrap heap. |
Attribute name | Related methods | |
---|---|---|
android:cacheColorHint | Indicates that this list will always be drawn on top of solid, single-color opaque background. | |
android:drawSelectorOnTop | setDrawSelectorOnTop(boolean) |
When set to true, the selector will be drawn over the selected item. |
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: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. |
Value | ||||
---|---|---|---|---|
int | TRANSCRIPT_MODE_ALWAYS_SCROLL | The list will automatically scroll to the bottom, no matter what items are currently visible. | 2 | 0x00000002 |
int | TRANSCRIPT_MODE_DISABLED | Disables the transcript mode. | 0 | 0x00000000 |
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. | 1 | 0x00000001 |
AbsListView(Context context) | ||||||
AbsListView(Context context, AttributeSet attrs) | ||||||
AbsListView(Context context, AttributeSet attrs, int defStyle) |
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 associated with the text filter | ||||||
void | beforeTextChanged(CharSequence s, int start, int count, int after) | |||||
For our text watcher that associated with the text filter | ||||||
void | clearTextFilter() | |||||
Clear the text filter. | ||||||
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 | ||||||
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. | ||||||
int | getTranscriptMode() | |||||
Returns the current transcript mode. | ||||||
boolean | hasTextFilter() | |||||
Returns if the ListView currently has a text filter. | ||||||
void | invalidateViews() | |||||
Causes all the views to be rebuilt and redrawn. | ||||||
boolean | isScrollingCacheEnabled() | |||||
Indicates whether the children's drawing cache is used during a scroll. | ||||||
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 | 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 | onKeyUp(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. | ||||||
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 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. | ||||||
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 | 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 | setDrawSelectorOnTop(boolean onTop) | |||||
Controls whether the selection highlight drawable should be drawn on top of the item or behind it. | ||||||
void | setFilterText(String filterText) | |||||
Sets the initial value for the text filter. | ||||||
void | setOnScrollListener(AbsListView.OnScrollListener l) | |||||
Set the listener that will receive notifications every time the list scrolls. | ||||||
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 | setScrollIndicators(View up, View down) | |||||
void | setScrollingCacheEnabled(boolean enabled) | |||||
Enables or disables the children's drawing cache during a scroll. | ||||||
void | setSelector(int resID) | |||||
Set a Drawable that should be used to highlight the currently selected item. | ||||||
void | setSelector(Drawable sel) | |||||
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. | ||||||
boolean | showContextMenuForChild(View originalView) | |||||
Bring up a context menu for the specified view or its ancestors. | ||||||
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. |
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. | ||||||
ContextMenu.ContextMenuInfo | getContextMenuInfo() | |||||
Views should implement this if they have extra information to associate with the context menu. | ||||||
float | getTopFadingEdgeStrength() | |||||
Returns the strength, or intensity, of the top faded edge. | ||||||
void | handleDataChanged() | |||||
boolean | isInFilterMode() | |||||
Indicates whether this view is in filter mode. | ||||||
void | layoutChildren() | |||||
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 | 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) | |||||
Called from layout when this view should assign a size and position to each of its children. | ||||||
void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) | |||||
Measure the view and its content to determine the measured width and the measured height. |
||||||
void | onSizeChanged(int w, int h, int oldw, int oldh) | |||||
This is called during layout when the size of this view has changed. |
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.
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.
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.
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.
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.
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.
Must be one of the following constant values.
Constant | Value | Description |
---|---|---|
disabled | 0 | Disables transcript mode. This is the default value. |
normal | 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. |
alwaysScroll | 2 | The list will automatically scroll to the bottom, no matter what items are currently visible. |
This corresponds to the global attribute resource symbol transcriptMode.
views | Touchable views found so far |
---|
attrs | the attributes to build the layout parameters from |
---|
r | The rectangle to fill in, in this view's coordinates. |
---|
Notifies the end of a filtering operation.
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:
ev | The motion event being dispatched down the hierarchy. |
---|
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
state | The frozen state that had previously been returned by onSaveInstanceState(). |
---|
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.
ev | The motion event. |
---|
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
x | X in local coordinate |
---|---|
y | Y in local coordinate |
x | X in local coordinate |
---|---|
y | Y in local coordinate |
views | A list into which to put the reclaimed views |
---|
color | The background color |
---|
onTop | If true, the selector will be drawn on the item it is highlighting. The default is false. |
---|
filterText | The text to use for the filter. |
---|
l | the scroll listener |
---|
listener | The recycler listener to be notified of views set aside in the recycler. |
---|
enabled | true to enable the scroll cache, false otherwise |
---|
resID | A Drawable resource to use as the selection highlight. |
---|
stackFromBottom | true to pin the view's content to the bottom edge, false to pin the view's content to the top edge |
---|
textFilterEnabled | true to enable type filtering, false otherwise |
---|
mode | the transcript mode to set |
---|
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.
Be sure to call through to the super class when overriding this function.
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. |
---|
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 computeHorizontalScrollRange() and computeVerticalScrollOffset().
The default extent is the drawing height of this view.
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.
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().
The default range is the drawing height of this view.
canvas | the canvas on which to draw the view |
---|
pressed | The new pressed state |
---|
Be sure to call through to the superclass when overriding this function.
p | The layout parameters to convert into a suitable set of layout parameters for this ViewGroup. |
---|
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. |
---|
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.
|
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 |
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()).
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. |
w | Current width of this view. |
---|---|
h | Current height of this view. |
oldw | Old width of this view. |
oldh | Old height of this view. |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |