Stay organized with collections
Save and categorize content based on your preferences.
public
static
interface
AbsListView.OnScrollListener
android.widget.AbsListView.OnScrollListener
|
Interface definition for a callback to be invoked when the list or grid
has been scrolled.
Summary
Public methods |
abstract
void
|
onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
Callback method to be invoked when the list or grid has been scrolled.
|
abstract
void
|
onScrollStateChanged(AbsListView view, int scrollState)
Callback method to be invoked while the list view or grid view is being scrolled.
|
Constants
public static final int SCROLL_STATE_FLING
The user had previously been scrolling using touch and had performed a fling. The
animation is now coasting to a stop
Constant Value:
2
(0x00000002)
public static final int SCROLL_STATE_IDLE
The view is not scrolling. Note navigating the list using the trackball counts as
being in the idle state since these transitions are not animated.
Constant Value:
0
(0x00000000)
public static final int SCROLL_STATE_TOUCH_SCROLL
The user is scrolling using touch, and their finger is still on the screen
Constant Value:
1
(0x00000001)
Public methods
public abstract void onScroll (AbsListView view,
int firstVisibleItem,
int visibleItemCount,
int totalItemCount)
Callback method to be invoked when the list or grid has been scrolled. This will be
called after the scroll has completed
Parameters |
view |
AbsListView : The view whose scroll state is being reported |
firstVisibleItem |
int : the index of the first visible cell (ignore if
visibleItemCount == 0) |
visibleItemCount |
int : the number of visible cells |
totalItemCount |
int : the number of items in the list adapter |
public abstract void onScrollStateChanged (AbsListView view,
int scrollState)
Callback method to be invoked while the list view or grid view is being scrolled. If the
view is being scrolled, this method will be called before the next frame of the scroll is
rendered. In particular, it will be called before any calls to
Adapter.getView(int, View, ViewGroup)
.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# AbsListView.OnScrollListener\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nAbsListView.OnScrollListener\n============================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/widget/AbsListView.OnScrollListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nAbsListView.OnScrollListener\n`\n\n\n`\n\n\n`\n\n|---------------------------------------------|\n| android.widget.AbsListView.OnScrollListener |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface definition for a callback to be invoked when the list or grid\nhas been scrolled.\n\nSummary\n-------\n\n| ### Constants ||\n|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `int` | [SCROLL_STATE_FLING](/reference/android/widget/AbsListView.OnScrollListener#SCROLL_STATE_FLING) The user had previously been scrolling using touch and had performed a fling. |\n| `int` | [SCROLL_STATE_IDLE](/reference/android/widget/AbsListView.OnScrollListener#SCROLL_STATE_IDLE) The view is not scrolling. |\n| `int` | [SCROLL_STATE_TOUCH_SCROLL](/reference/android/widget/AbsListView.OnScrollListener#SCROLL_STATE_TOUCH_SCROLL) The user is scrolling using touch, and their finger is still on the screen |\n\n| ### Public methods ||\n|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onScroll](/reference/android/widget/AbsListView.OnScrollListener#onScroll(android.widget.AbsListView,%20int,%20int,%20int))`(`[AbsListView](/reference/android/widget/AbsListView)` view, int firstVisibleItem, int visibleItemCount, int totalItemCount) ` Callback method to be invoked when the list or grid has been scrolled. |\n| ` abstract void` | ` `[onScrollStateChanged](/reference/android/widget/AbsListView.OnScrollListener#onScrollStateChanged(android.widget.AbsListView,%20int))`(`[AbsListView](/reference/android/widget/AbsListView)` view, int scrollState) ` Callback method to be invoked while the list view or grid view is being scrolled. |\n\nConstants\n---------\n\n### SCROLL_STATE_FLING\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int SCROLL_STATE_FLING\n```\n\nThe user had previously been scrolling using touch and had performed a fling. The\nanimation is now coasting to a stop\n\n\u003cbr /\u003e\n\nConstant Value:\n\n2\n(0x00000002)\n\n\n### SCROLL_STATE_IDLE\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int SCROLL_STATE_IDLE\n```\n\nThe view is not scrolling. Note navigating the list using the trackball counts as\nbeing in the idle state since these transitions are not animated.\n\n\u003cbr /\u003e\n\nConstant Value:\n\n0\n(0x00000000)\n\n\n### SCROLL_STATE_TOUCH_SCROLL\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static final int SCROLL_STATE_TOUCH_SCROLL\n```\n\nThe user is scrolling using touch, and their finger is still on the screen\n\n\u003cbr /\u003e\n\nConstant Value:\n\n1\n(0x00000001)\n\n\nPublic methods\n--------------\n\n### onScroll\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onScroll (AbsListView view, \n int firstVisibleItem, \n int visibleItemCount, \n int totalItemCount)\n```\n\nCallback method to be invoked when the list or grid has been scrolled. This will be\ncalled after the scroll has completed\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------------|-------------------------------------------------------------------------------------|\n| `view` | `AbsListView`: The view whose scroll state is being reported \u003cbr /\u003e |\n| `firstVisibleItem` | `int`: the index of the first visible cell (ignore if visibleItemCount == 0) \u003cbr /\u003e |\n| `visibleItemCount` | `int`: the number of visible cells \u003cbr /\u003e |\n| `totalItemCount` | `int`: the number of items in the list adapter \u003cbr /\u003e |\n\n### onScrollStateChanged\n\nAdded in [API level 1](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onScrollStateChanged (AbsListView view, \n int scrollState)\n```\n\nCallback method to be invoked while the list view or grid view is being scrolled. If the\nview is being scrolled, this method will be called before the next frame of the scroll is\nrendered. In particular, it will be called before any calls to\n[Adapter.getView(int, View, ViewGroup)](/reference/android/widget/Adapter#getView(int,%20android.view.View,%20android.view.ViewGroup)).\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `view` | `AbsListView`: The view whose scroll state is being reported \u003cbr /\u003e |\n| `scrollState` | `int`: The current scroll state. One of [SCROLL_STATE_TOUCH_SCROLL](/reference/android/widget/AbsListView.OnScrollListener#SCROLL_STATE_TOUCH_SCROLL) or [SCROLL_STATE_IDLE](/reference/android/widget/AbsListView.OnScrollListener#SCROLL_STATE_IDLE). \u003cbr /\u003e |"]]