Stay organized with collections
Save and categorize content based on your preferences.
interface OnScrollListener
Interface definition for a callback to be invoked when the list or grid has been scrolled.
Summary
Constants |
static Int |
The user had previously been scrolling using touch and had performed a fling.
|
static Int |
The view is not scrolling.
|
static Int |
The user is scrolling using touch, and their finger is still on the screen
|
Public methods |
abstract Unit |
Callback method to be invoked when the list or grid has been scrolled.
|
abstract Unit |
Callback method to be invoked while the list view or grid view is being scrolled.
|
Constants
static val SCROLL_STATE_FLING: Int
The user had previously been scrolling using touch and had performed a fling. The animation is now coasting to a stop
Value: 2
static val SCROLL_STATE_IDLE: Int
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.
Value: 0
static val SCROLL_STATE_TOUCH_SCROLL: Int
The user is scrolling using touch, and their finger is still on the screen
Value: 1
Public methods
abstract fun onScroll(
view: AbsListView!,
firstVisibleItem: Int,
visibleItemCount: Int,
totalItemCount: Int
): Unit
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 |
abstract fun onScrollStateChanged(
view: AbsListView!,
scrollState: Int
): Unit
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnScrollListener\n================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/widget/AbsListView.OnScrollListener \"View this page in Java\") \n\n```\ninterface OnScrollListener\n```\n\n|--------------------------------------------------|\n| [android.widget.AbsListView.OnScrollListener](#) |\n\nInterface definition for a callback to be invoked when the list or grid has been scrolled.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SCROLL_STATE_FLING](#SCROLL_STATE_FLING:kotlin.Int) The user had previously been scrolling using touch and had performed a fling. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SCROLL_STATE_IDLE](#SCROLL_STATE_IDLE:kotlin.Int) The view is not scrolling. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [SCROLL_STATE_TOUCH_SCROLL](#SCROLL_STATE_TOUCH_SCROLL:kotlin.Int) The user is scrolling using touch, and their finger is still on the screen |\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onScroll](#onScroll(android.widget.AbsListView,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int))`(`view:` `[AbsListView](/reference/kotlin/android/widget/AbsListView)!`, `firstVisibleItem:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `visibleItemCount:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `totalItemCount:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Callback method to be invoked when the list or grid has been scrolled. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onScrollStateChanged](#onScrollStateChanged(android.widget.AbsListView,%20kotlin.Int))`(`view:` `[AbsListView](/reference/kotlin/android/widget/AbsListView)!`, `scrollState:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` 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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val SCROLL_STATE_FLING: Int\n```\n\nThe user had previously been scrolling using touch and had performed a fling. The animation is now coasting to a stop \n\n Value: 2\n\n### SCROLL_STATE_IDLE\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val SCROLL_STATE_IDLE: Int\n```\n\nThe view is not scrolling. Note navigating the list using the trackball counts as being in the idle state since these transitions are not animated. \n\n Value: 0\n\n### SCROLL_STATE_TOUCH_SCROLL\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val SCROLL_STATE_TOUCH_SCROLL: Int\n```\n\nThe user is scrolling using touch, and their finger is still on the screen \n\n Value: 1\n\nPublic methods\n--------------\n\n### onScroll\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScroll(\n view: AbsListView!, \n firstVisibleItem: Int, \n visibleItemCount: Int, \n totalItemCount: Int\n): Unit\n```\n\nCallback method to be invoked when the list or grid has been scrolled. This will be called after the scroll has completed\n\n| Parameters ||\n|--------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|\n| `view` | [AbsListView](/reference/kotlin/android/widget/AbsListView)!: The view whose scroll state is being reported |\n| `firstVisibleItem` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the index of the first visible cell (ignore if visibleItemCount == 0) |\n| `visibleItemCount` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the number of visible cells |\n| `totalItemCount` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the number of items in the list adapter |\n\n### onScrollStateChanged\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onScrollStateChanged(\n view: AbsListView!, \n scrollState: Int\n): Unit\n```\n\nCallback 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)](/reference/kotlin/android/widget/Adapter#getView(kotlin.Int,%20android.view.View,%20android.view.ViewGroup)).\n\n| Parameters ||\n|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `view` | [AbsListView](/reference/kotlin/android/widget/AbsListView)!: The view whose scroll state is being reported |\n| `scrollState` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The current scroll state. One of [SCROLL_STATE_TOUCH_SCROLL](#SCROLL_STATE_TOUCH_SCROLL:kotlin.Int) or [SCROLL_STATE_IDLE](#SCROLL_STATE_IDLE:kotlin.Int). |"]]