# Preference.SummaryProvider

Artifact: [androidx.preference:preference](https://developer.android.com/jetpack/androidx/releases/preference) [View Source](https://cs.android.com/search?q=file:androidx/preference/Preference.java+class:androidx.preference.Preference.SummaryProvider) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/preference#1.1.0)

*** ** * ** ***


```
public interface Preference.SummaryProvider<T extends Preference>
```

<br />

Known direct subclasses [EditTextPreference.SimpleSummaryProvider](https://developer.android.com/reference/androidx/preference/EditTextPreference.SimpleSummaryProvider), [ListPreference.SimpleSummaryProvider](https://developer.android.com/reference/androidx/preference/ListPreference.SimpleSummaryProvider)

|---|---|
| `https://developer.android.com/reference/androidx/preference/EditTextPreference.SimpleSummaryProvider` | A simple `https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider` implementation for an `https://developer.android.com/reference/androidx/preference/EditTextPreference`. |
| `https://developer.android.com/reference/androidx/preference/ListPreference.SimpleSummaryProvider` | A simple `https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider` implementation for a `https://developer.android.com/reference/androidx/preference/ListPreference`. |

*** ** * ** ***

Interface definition for a callback to be invoked when the summary of this `https://developer.android.com/reference/androidx/preference/Preference` is requested (typically when this preference is added to the hierarchy or its value is updated). Implement this to allow dynamically configuring a summary.

If a SummaryProvider is set, `https://developer.android.com/reference/androidx/preference/Preference#setSummary(java.lang.CharSequence)` will throw an exception, and any existing value for the summary will not be used. The value returned by the SummaryProvider will be used instead whenever `https://developer.android.com/reference/androidx/preference/Preference#getSummary()` is called on this preference.

Simple implementations are provided for `https://developer.android.com/reference/androidx/preference/EditTextPreference` and `https://developer.android.com/reference/androidx/preference/ListPreference`. To enable these implementations, use `https://developer.android.com/reference/androidx/preference/Preference#setSummaryProvider(androidx.preference.Preference.SummaryProvider)` with `https://developer.android.com/reference/androidx/preference/EditTextPreference.SimpleSummaryProvider#getInstance()` or `https://developer.android.com/reference/androidx/preference/ListPreference.SimpleSummaryProvider#getInstance()`.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/preference/Preference>` | The Preference class that a summary is being requested for |

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html` | `https://developer.android.com/reference/androidx/preference/Preference.SummaryProvider#provideSummary(T)(@https://developer.android.com/reference/androidx/annotation/NonNull T preference)` Called whenever `https://developer.android.com/reference/androidx/preference/Preference#getSummary()` is called on this preference. |

## Public methods

### provideSummary

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/preference#1.1.0)

```
abstract @Nullable CharSequence provideSummary(@NonNull T preference)
```

Called whenever `https://developer.android.com/reference/androidx/preference/Preference#getSummary()` is called on this preference.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T preference` | This preference |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/CharSequence.html` | A CharSequence that will be displayed as the summary for this preference |