# DialogPreference.TargetFragment

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

*** ** * ** ***


```
public interface DialogPreference.TargetFragment
```

<br />

Known direct subclasses [PreferenceFragmentCompat](https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat), [PreferenceFragment](https://developer.android.com/reference/androidx/preference/PreferenceFragment)

|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat` | A PreferenceFragmentCompat is the entry point to using the Preference library. |
| `https://developer.android.com/reference/androidx/preference/PreferenceFragment` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat` instead <br /> |

Known indirect subclasses [BaseLeanbackPreferenceFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragmentCompat), [BaseLeanbackPreferenceFragment](https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragment), [LeanbackPreferenceFragmentCompat](https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat), [LeanbackPreferenceFragment](https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragment)

|---|---|
| `https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragmentCompat` | This fragment provides a preference fragment with leanback-style behavior, suitable for embedding into broader UI elements. |
| `https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragment` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/leanback/preference/BaseLeanbackPreferenceFragmentCompat` <br /> |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat` | This fragment provides a fully decorated leanback-style preference fragment, including a list background and header. |
| `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragment` | **This class is deprecated.** Use `https://developer.android.com/reference/androidx/leanback/preference/LeanbackPreferenceFragmentCompat` <br /> |

*** ** * ** ***

Interface for `https://developer.android.com/reference/androidx/preference/PreferenceFragmentCompat`s to implement to allow `https://developer.android.com/reference/androidx/preference/DialogPreference`s to find the preference that launched the dialog.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/Nullable T` | `<T extends https://developer.android.com/reference/androidx/preference/Preference> https://developer.android.com/reference/androidx/preference/DialogPreference.TargetFragment#findPreference(java.lang.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key)` Finds a `https://developer.android.com/reference/androidx/preference/Preference` with the given key. |

## Public methods

### findPreference

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

```
abstract @Nullable T <T extends Preference> findPreference(@NonNull CharSequence key)
```

Finds a `https://developer.android.com/reference/androidx/preference/Preference` with the given key. Returns `null` if no `https://developer.android.com/reference/androidx/preference/Preference` could be found with the given key.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html key` | The key of the `https://developer.android.com/reference/androidx/preference/Preference` to retrieve |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable T` | The `https://developer.android.com/reference/androidx/preference/Preference` with the key, or `null` |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/preference/PreferenceGroup#findPreference(java.lang.CharSequence)` |   |