Stay organized with collections
Save and categorize content based on your preferences.
OnClickListener
interface OnClickListener
Known Indirect Subclasses
|
Interface used to allow the creator of a dialog to run some code when an item on the dialog is clicked.
Summary
Public methods |
abstract Unit |
This method will be invoked when a button in the dialog is clicked.
|
Public methods
onClick
abstract fun onClick(
dialog: DialogInterface!,
which: Int
): Unit
This method will be invoked when a button in the dialog is 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,["# DialogInterface.OnClickListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnClickListener\n===============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/content/DialogInterface.OnClickListener \"View this page in Java\") \n\n```\ninterface OnClickListener\n```\n\n|------------------------------------------------------|\n| [android.content.DialogInterface.OnClickListener](#) |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [DatePickerDialog](../app/DatePickerDialog.html#), [DialogPreference](../preference/DialogPreference.html#), [Spinner](../widget/Spinner.html#), [TimePickerDialog](../app/TimePickerDialog.html#) |----------------------------------------------------------|------------------------------------------------------------------------------------------------------| | [DatePickerDialog](../app/DatePickerDialog.html#) | A simple dialog containing an [android.widget.DatePicker](../widget/DatePicker.html#). | | [DialogPreference](../preference/DialogPreference.html#) | A base class for [Preference](../preference/Preference.html#) objects that are dialog-based. | | [Spinner](../widget/Spinner.html#) | A view that displays one child at a time and lets the user pick among them. | | [TimePickerDialog](../app/TimePickerDialog.html#) | A dialog that prompts the user for the time of day using a [TimePicker](../widget/TimePicker.html#). | |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Indirect Subclasses [EditTextPreference](../preference/EditTextPreference.html#), [ListPreference](../preference/ListPreference.html#), [MultiSelectListPreference](../preference/MultiSelectListPreference.html#) |----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | [EditTextPreference](../preference/EditTextPreference.html#) | A [Preference](../preference/Preference.html#) that allows for string input. | | [ListPreference](../preference/ListPreference.html#) | A [Preference](../preference/Preference.html#) that displays a list of entries as a dialog. | | [MultiSelectListPreference](../preference/MultiSelectListPreference.html#) | A [Preference](../preference/Preference.html#) that displays a list of entries as a dialog. | |\n\nInterface used to allow the creator of a dialog to run some code when an item on the dialog is clicked.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onClick](#onClick(android.content.DialogInterface,%20kotlin.Int))`(`dialog:` `[DialogInterface](/reference/kotlin/android/content/DialogInterface)!`, `which:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` This method will be invoked when a button in the dialog is clicked. |\n\nPublic methods\n--------------\n\n### onClick\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onClick(\n dialog: DialogInterface!, \n which: Int\n): Unit\n```\n\nThis method will be invoked when a button in the dialog is clicked.\n\n| Parameters ||\n|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dialog` | [DialogInterface](/reference/kotlin/android/content/DialogInterface)!: the dialog that received the click |\n| `which` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the button that was clicked (ex. [DialogInterface.BUTTON_POSITIVE](/reference/kotlin/android/content/DialogInterface#BUTTON_POSITIVE:kotlin.Int)) or the position of the item clicked |"]]