Stay organized with collections
Save and categorize content based on your preferences.
OnItemClickListener
interface OnItemClickListener
Interface definition for a callback to be invoked when an item in this AdapterView has been clicked.
Summary
Public methods |
abstract Unit |
Callback method to be invoked when an item in this AdapterView has been clicked.
|
Public methods
onItemClick
abstract fun onItemClick(
parent: AdapterView<*>!,
view: View!,
position: Int,
id: Long
): Unit
Callback method to be invoked when an item in this AdapterView has been clicked.
Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
Parameters |
parent |
AdapterView<*>!: The AdapterView where the click happened. |
view |
View!: The view within the AdapterView that was clicked (this will be a view provided by the adapter) |
position |
Int: The position of the view in the adapter. |
id |
Long: The row id of the item that was clicked. |
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,["# AdapterView.OnItemClickListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnItemClickListener\n===================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/widget/AdapterView.OnItemClickListener \"View this page in Java\") \n\n```\ninterface OnItemClickListener\n```\n\n|-----------------------------------------------------|\n| [android.widget.AdapterView.OnItemClickListener](#) |\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [CharacterPickerDialog](../text/method/CharacterPickerDialog.html#), [PreferenceScreen](../preference/PreferenceScreen.html#) |---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------| | [CharacterPickerDialog](../text/method/CharacterPickerDialog.html#) | Dialog for choosing accented characters related to a base character. | | [PreferenceScreen](../preference/PreferenceScreen.html#) | Represents a top-level [Preference](../preference/Preference.html#) that is the root of a Preference hierarchy. | |\n\nInterface definition for a callback to be invoked when an item in this AdapterView has been clicked.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onItemClick](#onItemClick(android.widget.AdapterView,%20android.view.View,%20kotlin.Int,%20kotlin.Long))`(`parent:` `[AdapterView](/reference/kotlin/android/widget/AdapterView)\u003c*\u003e!`, `view:` `[View](../view/View.html#)!`, `position:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `id:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Callback method to be invoked when an item in this AdapterView has been clicked. |\n\nPublic methods\n--------------\n\n### onItemClick\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onItemClick(\n parent: AdapterView\u003c*\u003e!, \n view: View!, \n position: Int, \n id: Long\n): Unit\n```\n\nCallback method to be invoked when an item in this AdapterView has been clicked.\n\nImplementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.\n\n| Parameters ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------|\n| `parent` | [AdapterView](/reference/kotlin/android/widget/AdapterView)\\\u003c\\*\\\u003e!: The AdapterView where the click happened. |\n| `view` | [View](../view/View.html#)!: The view within the AdapterView that was clicked (this will be a view provided by the adapter) |\n| `position` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): The position of the view in the adapter. |\n| `id` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html): The row id of the item that was clicked. |"]]