I am using AndroidX's Preference library to manage my app's settings. My SettingsFragment derives from PreferenceFragmentCompat and loads the following layout:
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.preference.PreferenceScreen
android:key="screen_backup_key"
android:title="@string/local_database">
<androidx.preference.Preference
android:key="button_save_key"
android:title="@string/export" />
<androidx.preference.Preference
android:key="button_load_key"
android:title="@string/_import" />
</androidx.preference.PreferenceScreen>
<androidx.preference.Preference
android:key="screen_about"
android:title="@string/about" />
</androidx.preference.PreferenceScreen>
The layout is displayed correctly, but when I click on the nested PreferenceScreen entry nothing happens. It worked before with the PreferenceScreen from the Support Library, which is now deprecated.
I would expect to see the contents to this nested PreferenceScreen. What am I doing wrong?
It is not supported anymore in AndroidX's Preference Library.
You need a separate
PreferenceFragmentCompatfor each separate screen.You do it like this:
Here is the source for further reading.