In androidx.preference.Preference
(using Version 1.1.0-beta01) it is possible to set a summary provider, which I did inside the onCreatePreferences
method of a PreferenceFragmentCompat
.
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
...
val mySummaryProvider = Preference.SummaryProvider<Preference> {
val str = preferenceManager.sharedPreferences.getString(it.key, "")
doSomethingCool(str)
}
findPreference<Preference>("my_pref_id").summaryProvider = mySummarProvider
}
When I now update the preference (by using the preference editor) while the fragment is still visible, how do I notify the preference or the fragment that the summary provider should be called again (it isn't done automatically)? Unfortunately, I don't see any method or way to do that.
setSummary
in a preference change listener. But I still think thatSummaryProvider
would be nicer if only a way to notify of updates would be supported. – Katy