Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/content/DialogInterface.OnClickListener#pubmethods)

# DialogInterface.OnClickListener

*** ** * ** ***

` public static interface DialogInterface.OnClickListener `   
` `

|---|
| android.content.DialogInterface.OnClickListener |

Known indirect subclasses [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog), [DialogPreference](https://developer.android.com/reference/android/preference/DialogPreference), [EditTextPreference](https://developer.android.com/reference/android/preference/EditTextPreference), [ListPreference](https://developer.android.com/reference/android/preference/ListPreference), [MultiSelectListPreference](https://developer.android.com/reference/android/preference/MultiSelectListPreference), [Spinner](https://developer.android.com/reference/android/widget/Spinner), [TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) [DatePickerDialog](https://developer.android.com/reference/android/app/DatePickerDialog) A simple dialog containing an `https://developer.android.com/reference/android/widget/DatePicker`. [DialogPreference](https://developer.android.com/reference/android/preference/DialogPreference) *This class was deprecated in API level 29. Use the [AndroidX](https://developer.android.com/jetpack/androidx) [Preference Library](https://developer.android.com/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](https://developer.android.com/guide/topics/ui/settings).* [EditTextPreference](https://developer.android.com/reference/android/preference/EditTextPreference) *This class was deprecated in API level 29. Use the [AndroidX](https://developer.android.com/jetpack/androidx) [Preference Library](https://developer.android.com/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](https://developer.android.com/guide/topics/ui/settings).* [ListPreference](https://developer.android.com/reference/android/preference/ListPreference) *This class was deprecated in API level 29. Use the [AndroidX](https://developer.android.com/jetpack/androidx) [Preference Library](https://developer.android.com/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](https://developer.android.com/guide/topics/ui/settings).* [MultiSelectListPreference](https://developer.android.com/reference/android/preference/MultiSelectListPreference) *This class was deprecated in API level 29. Use the [AndroidX](https://developer.android.com/jetpack/androidx) [Preference Library](https://developer.android.com/reference/androidx/preference/package-summary) for consistent behavior across all devices. For more information on using the AndroidX Preference Library see [Settings](https://developer.android.com/guide/topics/ui/settings).* [Spinner](https://developer.android.com/reference/android/widget/Spinner) A view that displays one child at a time and lets the user pick among them. [TimePickerDialog](https://developer.android.com/reference/android/app/TimePickerDialog) A dialog that prompts the user for the time of day using a `https://developer.android.com/reference/android/widget/TimePicker`.   

*** ** * ** ***

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` | ` https://developer.android.com/reference/android/content/DialogInterface.OnClickListener#onClick(android.content.DialogInterface,%20int)(https://developer.android.com/reference/android/content/DialogInterface dialog, int which) ` This method will be invoked when a button in the dialog is clicked. |

## Public methods

### onClick

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract void onClick (DialogInterface dialog, 
                int which)
```

This method will be invoked when a button in the dialog is clicked.

<br />

| Parameters ||
|---|---|
| `dialog` | `DialogInterface`: the dialog that received the click <br /> |
| `which` | `int`: the button that was clicked (ex. `https://developer.android.com/reference/android/content/DialogInterface#BUTTON_POSITIVE`) or the position of the item clicked <br /> |