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 |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
AbsListView.LayoutParams | AbsListView extends LayoutParams to provide a place to hold the view type. | |||||||||
|
AbsListView.MultiChoiceModeListener |
A MultiChoiceModeListener receives events for
CHOICE_MODE_MULTIPLE_MODAL
.
|
|||||||||
|
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. | |||||||||
|
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|||||||||
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||
|
|
||||||||||
|
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Add any touchable views that are descendants of this view (possibly
including this view if it is touchable itself) to views.
|
||||||||||
|
For our text watcher that is associated with the text filter.
|
||||||||||
|
For our text watcher that is associated with the text filter.
|
||||||||||
|
Check if the items in the list can be scrolled in a certain direction.
|
||||||||||
|
For filtering we proxy an input connection to an internal text editor,
and this allows the proxying to happen.
|
||||||||||
|
Clear any choices previously set
|
||||||||||
|
Clear the text filter.
|
||||||||||
|
This defers a notifyDataSetChanged on the pending RemoteViewsAdapter if it has not
connected yet.
|
||||||||||
|
Manually render this view (and all of its children) to the given Canvas.
|
||||||||||
|
Returns a new set of layout parameters based on the supplied attributes set.
|
||||||||||
|
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 number of items currently selected.
|
||||||||||
|
Returns the set of checked items ids.
|
||||||||||
|
Returns the currently checked item.
|
||||||||||
|
Returns the set of checked items in the list.
|
||||||||||
|
|
||||||||||
|
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.
|
||||||||||
|
List padding is the maximum of the normal view's padding and the padding of the selector.
|
||||||||||
|
List padding is the maximum of the normal view's padding and the padding of the selector.
|
||||||||||
|
List padding is the maximum of the normal view's padding and the padding of the selector.
|
||||||||||
|
List padding is the maximum of the normal view's padding and the padding of the selector.
|
||||||||||
|
|
||||||||||
|
Returns the selector
Drawable
that is used to draw the
selection in the list.
|
||||||||||
|
Override this if your view is known to always be drawn on top of a solid color background,
and needs to draw fading edges.
|
||||||||||
|
Returns the list's text filter, if available.
|
||||||||||
|
Returns the current transcript mode.
|
||||||||||
|
Returns the width of the vertical scrollbar.
|
||||||||||
|
Returns if the ListView currently has a text filter.
|
||||||||||
|
Causes all the views to be rebuilt and redrawn.
|
||||||||||
|
Returns true if the fast scroller is set to always show on this view.
|
||||||||||
|
Returns true if the fast scroller is enabled.
|
||||||||||
|
Returns the checked state of the specified position.
|
||||||||||
|
Indicates whether the children's drawing cache is used during a scroll.
|
||||||||||
|
Returns the current state of the fast scroll feature.
|
||||||||||
|
Indicates whether the content of this view is pinned to, or stacked from,
the bottom edge.
|
||||||||||
|
Indicates whether type filtering is enabled for this view
|
||||||||||
|
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.
|
||||||||||
|
Called as the result of a call to
cancelPendingInputEvents()
on this view or
a parent view.
|
||||||||||
|
Return an InputConnection for editing of the filter text.
|
||||||||||
|
Notifies the end of a filtering operation. |
||||||||||
|
Implement this method to handle generic motion events.
|
||||||||||
|
Callback method to be invoked when the global layout state or the visibility of views
within the view tree changes
|
||||||||||
|
Initializes an
AccessibilityEvent
with information about
this View which is the event source.
|
||||||||||
|
Initializes an
AccessibilityNodeInfo
with information about this view.
|
||||||||||
|
Initializes an
AccessibilityNodeInfo
with information about a
particular item in the list.
|
||||||||||
|
Implement this method to intercept hover events before they are handled
by child views.
|
||||||||||
|
Implement this method to intercept all touch screen motion events.
|
||||||||||
|
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.
|
||||||||||
|
Default implementation of
KeyEvent.Callback.onKeyUp()
: perform clicking of the view
when
KEYCODE_DPAD_CENTER
or
KEYCODE_ENTER
is released.
|
||||||||||
|
Called back when the adapter connects to the RemoteViewsService.
|
||||||||||
|
Called back when the adapter disconnects from the RemoteViewsService.
|
||||||||||
|
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
onSaveInstanceState()
.
|
||||||||||
|
Called when any RTL property (layout direction or text direction or text alignment) has
been changed.
|
||||||||||
|
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.
|
||||||||||
|
For our text watcher that is associated with the text filter.
|
||||||||||
|
Implement this method to handle touch screen motion events.
|
||||||||||
|
Callback method to be invoked when the touch mode changes.
|
||||||||||
|
Called when the window containing this view gains or loses focus.
|
||||||||||
|
Performs the specified accessibility action on the view.
|
||||||||||
|
Call the OnItemClickListener, if it is defined.
|
||||||||||
|
Maps a point to a position in the list.
|
||||||||||
|
Maps a point to a the rowId of the item which intersects that point.
|
||||||||||
|
Move all views (excluding headers and footers) held by this AbsListView into the supplied
List.
|
||||||||||
|
Called when a child does not want this parent and its ancestors to
intercept touch events with
onInterceptTouchEvent(MotionEvent)
.
|
||||||||||
|
Call this when something has changed which has invalidated the
layout of this view.
|
||||||||||
|
Scrolls the list items within the view by a specified number of pixels.
|
||||||||||
|
Sends an accessibility event of the given type.
|
||||||||||
|
Sets the adapter that provides the data and the views to represent the data
in this widget.
|
||||||||||
|
When set to a non-zero value, the cache color hint indicates that this list is always drawn
on top of a solid, single-color, opaque background.
|
||||||||||
|
Defines the choice behavior for the List.
|
||||||||||
|
Controls whether the selection highlight drawable should be drawn on top of the item or
behind it.
|
||||||||||
|
Set whether or not the fast scroller should always be shown in place of
the standard scroll bars.
|
||||||||||
|
Specifies whether fast scrolling is enabled or disabled.
|
||||||||||
|
Sets the initial value for the text filter.
|
||||||||||
|
The amount of friction applied to flings.
|
||||||||||
|
Sets the checked state of the specified position.
|
||||||||||
|
Set a
AbsListView.MultiChoiceModeListener
that will manage the lifecycle of the
selection
ActionMode
.
|
||||||||||
|
Set the listener that will receive notifications every time the list scrolls.
|
||||||||||
|
Set the over-scroll mode for this view.
|
||||||||||
|
Sets the recycler listener to be notified whenever a View is set aside in
the recycler for later reuse.
|
||||||||||
|
Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService
through the specified intent.
|
||||||||||
|
Specify the style of the scrollbars. |
||||||||||
|
|
||||||||||
|
Enables or disables the children's drawing cache during a scroll.
|
||||||||||
|
|
||||||||||
|
Set a Drawable that should be used to highlight the currently selected item.
|
||||||||||
|
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.
|
||||||||||
|
When stack from bottom is set to true, the list fills its content starting from
the bottom of the view.
|
||||||||||
|
Enables or disables the type filter window.
|
||||||||||
|
Puts the list or grid into transcript mode.
|
||||||||||
|
Sets a scale factor for the fling velocity.
|
||||||||||
|
Set the position of the vertical scroll bar.
|
||||||||||
|
Bring up a context menu for the specified view or its ancestors.
|
||||||||||
|
Smoothly scroll by distance pixels over duration milliseconds.
|
||||||||||
|
Smoothly scroll to the specified adapter position.
|
||||||||||
|
Smoothly scroll to the specified adapter position.
|
||||||||||
|
Smoothly scroll to the specified adapter position.
|
||||||||||
|
Smoothly scroll to the specified adapter position.
|
||||||||||
|
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
||||||||||
|
Compute the vertical extent of the horizontal scrollbar's thumb within the vertical range. |
||||||||||
|
Compute the vertical offset of the vertical scrollbar's thumb within the horizontal range. |
||||||||||
|
Compute the vertical range that the vertical scrollbar represents. |
||||||||||
|
Called by draw to draw the child views.
|
||||||||||
|
Dispatch setPressed to all of this View's children.
|
||||||||||
|
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
||||||||||
|
Returns a set of default layout parameters.
|
||||||||||
|
Returns a safe set of layout parameters based on the supplied layout params.
|
||||||||||
|
Returns the strength, or intensity, of the bottom faded edge.
|
||||||||||
|
Amount by which to extend the bottom fading region.
|
||||||||||
|
Views should implement this if they have extra information to associate
with the context menu.
|
||||||||||
|
Amount by which to extend the left fading region.
|
||||||||||
|
Amount by which to extend the right fading region.
|
||||||||||
|
Returns the strength, or intensity, of the top faded edge.
|
||||||||||
|
Amount by which to extend the top fading region.
|
||||||||||
|
|
||||||||||
|
Indicates whether this view is in filter mode.
|
||||||||||
|
If the View draws content inside its padding and enables fading edges,
it needs to support padding offsets.
|
||||||||||
|
Subclasses must override this method to layout their children.
|
||||||||||
|
This is called when the view is attached to a window.
|
||||||||||
|
Generate the new
Drawable
state for
this view.
|
||||||||||
|
This is called when the view is detached from a window.
|
||||||||||
|
Gives this view a hint about whether is displayed or not.
|
||||||||||
|
Called by the view system when the focus state of this view changes.
|
||||||||||
|
Subclasses should NOT override this method but
layoutChildren()
instead.
|
||||||||||
|
Measure the view and its content to determine the measured width and the measured height. |
||||||||||
|
Called by
overScrollBy(int, int, int, int, int, int, int, int, boolean)
to
respond to the results of an over-scroll operation.
|
||||||||||
|
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
|
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
.
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.
Constant | Value | Description |
---|---|---|
none
|
0 | Normal list that does not indicate choices. |
singleChoice
|
1 | The list allows up to one choice. |
multipleChoice
|
2 | The list allows multiple choices. |
multipleChoiceModal
|
3 | The list allows multiple choices in a custom selection mode. |
This corresponds to the global attribute
resource symbol
choiceMode
.
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
.
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
.
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
.
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
.
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
.
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
.
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
.
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.
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
.
The list allows multiple choices
The list allows multiple choices in a modal selection mode
Normal list that does not indicate choices
The list allows up to one choice
The list will automatically scroll to the bottom, no matter what items are currently visible.
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.
Add any touchable views that are descendants of this view (possibly including this view if it is touchable itself) to views.
views | Touchable views found so far |
---|
For our text watcher that is associated with the text filter. Does nothing.
For our text watcher that is associated with the text filter. Does nothing.
Check if the items in the list can be scrolled in a certain direction.
direction | Negative to check scrolling up, positive to check scrolling down. |
---|
For filtering we proxy an input connection to an internal text editor, and this allows the proxying to happen.
view | The View that is making the InputMethodManager call. |
---|
This defers a notifyDataSetChanged on the pending RemoteViewsAdapter if it has not connected yet.
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(android.graphics.Canvas)
instead of overriding this method.
If you do need to override this method, call the superclass version.
canvas | The Canvas to which the View is rendered. |
---|
Returns a new set of layout parameters based on the supplied attributes set.
attrs | the attributes to build the layout parameters from |
---|
ViewGroup.LayoutParams
or one
of its descendants
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 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 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 the currently checked item. The result is only valid if the choice
mode has been set to
CHOICE_MODE_SINGLE
.
INVALID_POSITION
if nothing is selected
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
.
null
if the choice
mode is set to
CHOICE_MODE_NONE
.
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 rectangle is the
getDrawingRect(android.graphics.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.
r | The rectangle to fill in, in this view's coordinates. |
---|
List padding is the maximum of the normal view's padding and the padding of the selector.
List padding is the maximum of the normal view's padding and the padding of the selector.
List padding is the maximum of the normal view's padding and the padding of the selector.
List padding is the maximum of the normal view's padding and the padding of the selector.
Returns the selector
Drawable
that is used to draw the
selection in the list.
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 list's text filter, if available.
Returns the width of the vertical scrollbar.
Returns if the ListView currently has a text filter.
Returns true if the fast scroller is set to always show on this view.
Returns true if the fast scroller is enabled.
Returns the checked state of the specified position. The result is only
valid if the choice mode has been set to
CHOICE_MODE_SINGLE
or
CHOICE_MODE_MULTIPLE
.
position | The item whose checked state to return |
---|
false
if choice mode
is invalid
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 the current state of the fast scroll feature.
Indicates whether the content of this view is pinned to, or stacked from, the bottom edge.
Indicates whether type filtering is enabled for this view
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.
Called as the result of a call to
cancelPendingInputEvents()
on this view or
a parent view.
This method is responsible for removing any pending high-level input events that were
posted to the event queue to run later. Custom view classes that post their own deferred
high-level events via
post(Runnable)
,
postDelayed(Runnable, long)
or
Handler
should override this method, call
super.onCancelPendingInputEvents()
and remove those callbacks as appropriate.
Return an InputConnection for editing of the filter text.
outAttrs | Fill in with attribute information about the connection. |
---|
Notifies the end of a filtering operation.
count | the number of values computed by the filter |
---|
Implement this method to handle generic motion events.
Generic motion events describe joystick movements, mouse hovers, track pad
touches, scroll wheel movements and other input events. The
source
of the motion event specifies
the class of input that was received. Implementations of this method
must examine the bits in the source before processing the event.
The following code example shows how this is done.
Generic motion events with source class
SOURCE_CLASS_POINTER
are delivered to the view under the pointer. All other generic motion events are
delivered to the focused view.
public boolean onGenericMotionEvent(MotionEvent event) { if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) { if (event.getAction() == MotionEvent.ACTION_MOVE) { // process the joystick movement... return true; } } if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { switch (event.getAction()) { case MotionEvent.ACTION_HOVER_MOVE: // process the mouse hover movement... return true; case MotionEvent.ACTION_SCROLL: // process the scroll wheel movement... return true; } } return super.onGenericMotionEvent(event); }
event | The generic motion event being processed. |
---|
Callback method to be invoked when the global layout state or the visibility of views within the view tree changes
Initializes an
AccessibilityEvent
with information about
this View which is the event source. In other words, the source of
an accessibility event is the view whose state change triggered firing
the event.
Example: Setting the password property of an event in addition to properties set by the super implementation:
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { super.onInitializeAccessibilityEvent(event); event.setPassword(true); }
If an
View.AccessibilityDelegate
has been specified via calling
setAccessibilityDelegate(AccessibilityDelegate)
its
onInitializeAccessibilityEvent(View, AccessibilityEvent)
is responsible for handling this call.
Note: Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.
event | The event to initialize. |
---|
Initializes an
AccessibilityNodeInfo
with information about this view.
The base implementation sets:
setParent(View)
,
setBoundsInParent(Rect)
,
setBoundsInScreen(Rect)
,
setPackageName(CharSequence)
,
setClassName(CharSequence)
,
setContentDescription(CharSequence)
,
setEnabled(boolean)
,
setClickable(boolean)
,
setFocusable(boolean)
,
setFocused(boolean)
,
setLongClickable(boolean)
,
setSelected(boolean)
,
Subclasses should override this method, call the super implementation, and set additional attributes.
If an
View.AccessibilityDelegate
has been specified via calling
setAccessibilityDelegate(AccessibilityDelegate)
its
onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo)
is responsible for handling this call.
info | The instance to initialize. |
---|
Initializes an
AccessibilityNodeInfo
with information about a
particular item in the list.
view | View representing the list item. |
---|---|
position | Position of the list item within the adapter. |
info | Node info to populate. |
Implement this method to intercept hover events before they are handled by child views.
This method is called before dispatching a hover event to a child of
the view group or to the view group's own
onHoverEvent(MotionEvent)
to allow
the view group a chance to intercept the hover event.
This method can also be used to watch all pointer motions that occur within
the bounds of the view group even when the pointer is hovering over
a child of the view group rather than over the view group itself.
The view group can prevent its children from receiving hover events by
implementing this method and returning
true
to indicate
that it would like to intercept hover events. The view group must
continuously return
true
from
onInterceptHoverEvent(MotionEvent)
for as long as it wishes to continue intercepting hover events from
its children.
Interception preserves the invariant that at most one view can be hovered at a time by transferring hover focus from the currently hovered child to the view group or vice-versa as needed.
If this method returns
true
and a child is already hovered, then the
child view will first receive a hover exit event and then the view group
itself will receive a hover enter event in
onHoverEvent(MotionEvent)
.
Likewise, if this method had previously returned
true
to intercept hover
events and instead returns
false
while the pointer is hovering
within the bounds of one of a child, then the view group will first receive a
hover exit event in
onHoverEvent(MotionEvent)
and then the hovered child will
receive a hover enter event.
The default implementation always returns false.
event | The motion event that describes the hover. |
---|
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:
ACTION_CANCEL
, and all further
events will be delivered to your onTouchEvent() method and no longer
appear here.
ev | The motion event being dispatched down the hierarchy. |
---|
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.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
keyCode |
A key code that represents the button pressed, from
KeyEvent
.
|
---|---|
event | The KeyEvent object that defines the button action. |
Default implementation of
KeyEvent.Callback.onKeyUp()
: perform clicking of the view
when
KEYCODE_DPAD_CENTER
or
KEYCODE_ENTER
is released.
Key presses in software keyboards will generally NOT trigger this listener, although some may elect to do so in some situations. Do not rely on this to catch software key presses.
keyCode |
A key code that represents the button pressed, from
KeyEvent
.
|
---|---|
event | The KeyEvent object that defines the button action. |
Called back when the adapter connects to the RemoteViewsService.
Called back when the adapter disconnects from the RemoteViewsService.
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
onSaveInstanceState()
. This function will never be called with a
null state.
state |
The frozen state that had previously been returned by
onSaveInstanceState()
.
|
---|
Called when any RTL property (layout direction or text direction or text alignment) has been changed. Subclasses need to override this method to take care of cached information that depends on the resolved layout direction, or to inform child views that inherit their layout direction. The default implementation does nothing.
layoutDirection | the direction of the layout |
---|
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.
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.
Implement this method to handle touch screen motion events.
If this method is used to detect click actions, it is recommended that
the actions be performed by implementing and calling
performClick()
. This will ensure consistent system behavior,
including:
ACTION_CLICK
when
accessibility features are enabled
ev | The motion event. |
---|
Callback method to be invoked when the touch mode changes.
isInTouchMode | True if the view hierarchy is now in touch mode, false otherwise. |
---|
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.
hasWindowFocus | True if the window containing this view now has focus, false otherwise. |
---|
Performs the specified accessibility action on the view. For
possible accessibility actions look at
AccessibilityNodeInfo
.
If an
View.AccessibilityDelegate
has been specified via calling
setAccessibilityDelegate(AccessibilityDelegate)
its
performAccessibilityAction(View, int, Bundle)
is responsible for handling this call.
action | The action to perform. |
---|---|
arguments | Optional action arguments. |
Call the OnItemClickListener, if it is defined. Performs all normal actions associated with clicking: reporting accessibility event, playing a sound, etc.
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. |
Maps a point to a position in the list.
x | X in local coordinate |
---|---|
y | Y in local coordinate |
INVALID_POSITION
if the point does not intersect an item.
Maps a point to a the rowId of the item which intersects that point.
x | X in local coordinate |
---|---|
y | Y in local coordinate |
INVALID_ROW_ID
if the point does not intersect an item.
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.
views | A list into which to put the reclaimed views |
---|
Called when a child does not want this parent and its ancestors to
intercept touch events with
onInterceptTouchEvent(MotionEvent)
.
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
disallowIntercept | True if the child does not want the parent to intercept touch events. |
---|
Call this when something has changed which has invalidated the
layout of this view. This will schedule a layout pass of the view
tree. This should not be called while the view hierarchy is currently in a layout
pass (
isInLayout()
. If layout is happening, the request may be honored at the
end of the current layout pass (and then layout will run again) or after the current
frame is drawn and the next layout occurs.
Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.
Scrolls the list items within the view by a specified number of pixels.
y | the amount of pixels to scroll by vertically |
---|
Sends an accessibility event of the given type. If accessibility is
not enabled this method has no effect. The default implementation calls
onInitializeAccessibilityEvent(AccessibilityEvent)
first
to populate information about the event source (this View), then calls
dispatchPopulateAccessibilityEvent(AccessibilityEvent)
to
populate the text content of the event source including its descendants,
and last calls
requestSendAccessibilityEvent(View, AccessibilityEvent)
on its parent to resuest sending of the event to interested parties.
If an
View.AccessibilityDelegate
has been specified via calling
setAccessibilityDelegate(AccessibilityDelegate)
its
sendAccessibilityEvent(View, int)
is
responsible for handling this call.
eventType |
The type of the event to send, as defined by several types from
AccessibilityEvent
, such as
TYPE_VIEW_CLICKED
or
TYPE_VIEW_HOVER_ENTER
.
|
---|
Sets the adapter that provides the data and the views to represent the data in this widget.
adapter | The adapter to use to create this view's content. |
---|
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)
).
color | The background color |
---|
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.
choiceMode |
One of
CHOICE_MODE_NONE
,
CHOICE_MODE_SINGLE
, or
CHOICE_MODE_MULTIPLE
|
---|
Controls whether the selection highlight drawable should be drawn on top of the item or behind it.
onTop | If true, the selector will be drawn on the item it is highlighting. The default is false. |
---|
Set whether or not the fast scroller should always be shown in place of the standard scroll bars. This will enable fast scrolling if it is not already enabled.
Fast scrollers shown in this way will not fade out and will be a permanent fixture within the list. This is best combined with an inset scroll bar style to ensure the scroll bar does not overlap content.
alwaysShow | true if the fast scroller should always be displayed, false otherwise |
---|
Specifies whether fast scrolling is enabled or disabled.
When fast scrolling is enabled, the user can quickly scroll through lists by dragging the fast scroll thumb.
If the adapter backing this list implements
SectionIndexer
, the
fast scroller will display section header previews as the user scrolls.
Additionally, the user will be able to quickly jump between sections by
tapping along the length of the scroll bar.
enabled | true to enable fast scrolling, false otherwise |
---|
Sets the initial value for the text filter.
filterText | The text to use for the filter. |
---|
The amount of friction applied to flings. The default value
is
getScrollFriction()
.
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
.
position | The item whose checked state is to be checked |
---|---|
value | The new checked state for the item |
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
.
listener | Listener that will manage the selection mode |
---|
Set the listener that will receive notifications every time the list scrolls.
l | the scroll listener |
---|
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.
mode | The new over-scroll mode for this view. |
---|
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.
listener | The recycler listener to be notified of views set aside in the recycler. |
---|
AbsListView.RecyclerListener
Sets up this AbsListView to use a remote views adapter which connects to a RemoteViewsService through the specified intent.
intent | the intent used to identify the RemoteViewsService for the adapter to connect to. |
---|
Specify the style of the scrollbars. The scrollbars can be overlaid or inset. When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, you can use SCROLLBARS_INSIDE_OVERLAY or SCROLLBARS_INSIDE_INSET. If you want them to appear at the edge of the view, ignoring the padding, then you can use SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET.
style | the style of the scrollbars. Should be one of SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_INSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY or SCROLLBARS_OUTSIDE_INSET. |
---|
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)
.
enabled | true to enable the scroll cache, false otherwise |
---|
Set a Drawable that should be used to highlight the currently selected item.
resID | A Drawable resource to use as the selection highlight. |
---|
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.
enabled | Whether or not to enable smooth scrollbar. |
---|
When stack from bottom is set to true, the list fills its content starting from the bottom of the view.
stackFromBottom | true to pin the view's content to the bottom edge, false to pin the view's content to the top edge |
---|
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.
textFilterEnabled | true to enable type filtering, false otherwise |
---|
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.
mode | the transcript mode to set |
---|
Sets a scale factor for the fling velocity. The initial scale factor is 1.0.
scale | The scale factor to multiply the velocity by. |
---|
Set the position of the vertical scroll bar. Should be one of
SCROLLBAR_POSITION_DEFAULT
,
SCROLLBAR_POSITION_LEFT
or
SCROLLBAR_POSITION_RIGHT
.
position | Where the vertical scroll bar should be positioned. |
---|
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.
originalView | The source view where the context menu was first invoked |
---|
Smoothly scroll by distance pixels over duration milliseconds.
distance | Distance to scroll in pixels. |
---|---|
duration | Duration of the scroll animation in milliseconds. |
Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.
position | Scroll to this adapter position. |
---|
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.
position | Scroll to this adapter position. |
---|---|
boundPosition | Do not scroll if it would move this adapter position out of view. |
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.
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 |
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.
position | Position to scroll to |
---|---|
offset |
Desired distance in pixels of
position
from the top
of the view when scrolling is finished
|
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.
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
computeVerticalScrollRange()
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.
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).
canvas | the canvas on which to draw the view |
---|
Dispatch setPressed to all of this View's children.
pressed | The new pressed state |
---|
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.
Returns a set of default layout parameters. These parameters are requested
when the View passed to
addView(View)
has no layout parameters
already set. If null is returned, an exception is thrown from addView.
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.
p | The layout parameters to convert into a suitable set of layout parameters for this ViewGroup. |
---|
ViewGroup.LayoutParams
or one
of its descendants
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.
Amount by which to extend the bottom fading region. Called only when
isPaddingOffsetRequired()
returns true.
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.
Amount by which to extend the left fading region. Called only when
isPaddingOffsetRequired()
returns true.
Amount by which to extend the right fading region. Called only when
isPaddingOffsetRequired()
returns true.
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.
Amount by which to extend the top fading region. Called only when
isPaddingOffsetRequired()
returns true.
Indicates whether this view is in filter mode. Filter mode can for instance be enabled by a user when typing on the keyboard.
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.
Subclasses must override this method to layout their children.
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(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after
onMeasure(int, int)
.
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()
.
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. |
---|
Drawable
state of
the view.
This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
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.
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.
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.
|
Subclasses should NOT override this method but
layoutChildren()
instead.
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
.
|
Called by
overScrollBy(int, int, int, int, int, int, int, int, boolean)
to
respond to the results of an over-scroll operation.
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 |
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.
w | Current width of this view. |
---|---|
h | Current height of this view. |
oldw | Old width of this view. |
oldh | Old height of this view. |