android / android-ktx

A set of Kotlin extensions for Android app development.
https://android.github.io/android-ktx/core-ktx/
7.47k stars 563 forks source link

androidx.preference.PreferenceFragment not derived from androidx.fragment.app.Fragment #575

Closed juergenzimmermann closed 6 years ago

juergenzimmermann commented 6 years ago

When you have e.g.

class Prefs : androidx.preference.PreferenceFragment() {...}

then you cannot implement in a Fragment class (derived from androidx.fragment.app.Fragment)

fragmentManager?.transaction { replace(R.id.details, Prefs()) }

because replace expects androidx.fragment.app.Fragment. However, the inheritance hierarchy is Prefs -> androidx.preference.PreferenceFragment -> android.app.Fragment

JakeWharton commented 6 years ago

Please file a feature request on b.android.com/new. This isn't a problem with core-ktx, but that the preference androidx library doesn't use androidx fragments.

gabrielittner commented 6 years ago

@juergenzimmermann You need to extend androidx.preference.PreferenceFragmentCompat.

Here is an issue that requests to deprecate the androidx PreferenceFrament classes that extend platform fragments https://issuetracker.google.com/issues/79405956