Stay organized with collections
Save and categorize content based on your preferences.
DialogInterface.OnClickListener
public
static
interface
DialogInterface.OnClickListener
android.content.DialogInterface.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
void
|
onClick(DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked.
|
Public methods
onClick
public abstract void onClick (DialogInterface dialog,
int which)
This method will be invoked when a button in the dialog is clicked.
Parameters |
dialog |
DialogInterface : the dialog that received the click |
which |
int : the button that was clicked (ex.
DialogInterface.BUTTON_POSITIVE ) or the position
of the item 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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \n\nDialogInterface.OnClickListener\n===============================\n\n*** ** * ** ***\n\n[Kotlin](/reference/kotlin/android/content/DialogInterface.OnClickListener \"View this page in Kotlin\") \\|Java\n\n\n`\npublic\nstatic\n\n\ninterface\nDialogInterface.OnClickListener\n`\n\n\n`\n\n\n`\n\n|-------------------------------------------------|\n| android.content.DialogInterface.OnClickListener |\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known indirect subclasses [DatePickerDialog](/reference/android/app/DatePickerDialog), [DialogPreference](/reference/android/preference/DialogPreference), [EditTextPreference](/reference/android/preference/EditTextPreference), [ListPreference](/reference/android/preference/ListPreference), [MultiSelectListPreference](/reference/android/preference/MultiSelectListPreference), [Spinner](/reference/android/widget/Spinner), [TimePickerDialog](/reference/android/app/TimePickerDialog) |--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DatePickerDialog](/reference/android/app/DatePickerDialog) | A simple dialog containing an [DatePicker](/reference/android/widget/DatePicker). | | [DialogPreference](/reference/android/preference/DialogPreference) | *This class was deprecated in API level 29. Use the [AndroidX](/jetpack/androidx) [Preference Library](/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](/guide/topics/ui/settings).* | | [EditTextPreference](/reference/android/preference/EditTextPreference) | *This class was deprecated in API level 29. Use the [AndroidX](/jetpack/androidx) [Preference Library](/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](/guide/topics/ui/settings).* | | [ListPreference](/reference/android/preference/ListPreference) | *This class was deprecated in API level 29. Use the [AndroidX](/jetpack/androidx) [Preference Library](/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](/guide/topics/ui/settings).* | | [MultiSelectListPreference](/reference/android/preference/MultiSelectListPreference) | *This class was deprecated in API level 29. Use the [AndroidX](/jetpack/androidx) [Preference Library](/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](/guide/topics/ui/settings).* | | [Spinner](/reference/android/widget/Spinner) | A view that displays one child at a time and lets the user pick among them. | | [TimePickerDialog](/reference/android/app/TimePickerDialog) | A dialog that prompts the user for the time of day using a [TimePicker](/reference/android/widget/TimePicker). | |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInterface used to allow the creator of a dialog to run some code when an\nitem on the dialog is clicked.\n\nSummary\n-------\n\n| ### Public methods ||\n|------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract void` | ` `[onClick](/reference/android/content/DialogInterface.OnClickListener#onClick(android.content.DialogInterface,%20int))`(`[DialogInterface](/reference/android/content/DialogInterface)` dialog, int which) ` 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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract void onClick (DialogInterface dialog, \n int which)\n```\n\nThis method will be invoked when a button in the dialog is clicked.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `dialog` | `DialogInterface`: the dialog that received the click \u003cbr /\u003e |\n| `which` | `int`: the button that was clicked (ex. [DialogInterface.BUTTON_POSITIVE](/reference/android/content/DialogInterface#BUTTON_POSITIVE)) or the position of the item clicked \u003cbr /\u003e |"]]