Preference.SummaryProvider


public interface Preference.SummaryProvider<T extends Preference>


Interface definition for a callback to be invoked when the summary of this 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, setSummary 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 getSummary is called on this preference.

Simple implementations are provided for EditTextPreference and ListPreference. To enable these implementations, use setSummaryProvider with getInstance or getInstance.

Parameters
<T extends Preference>

The Preference class that a summary is being requested for

Summary

Public methods

abstract @Nullable CharSequence
provideSummary(@NonNull T preference)

Called whenever getSummary is called on this preference.

Public methods

provideSummary

Added in 1.1.0
abstract @Nullable CharSequence provideSummary(@NonNull T preference)

Called whenever getSummary is called on this preference.

Parameters
@NonNull T preference

This preference

Returns
@Nullable CharSequence

A CharSequence that will be displayed as the summary for this preference