preferenceFragement没有设置共享preferences后才preferenceFragment是装 [英] PreferenceFragement does not set SharedPreferences until after PreferenceFragment is loaded
问题描述
在preferenceFragment preferences没有被添加到我的共享preference地图后,直到我加载preference片段。
-
这是preferenceFragment的预期行为?
-
如果有,是什么甚至之前应用在所有的
preferences.xml
指定的默认共享preferences的最佳方式用户访问preference片段?
您可以把 preferenceManager.setDefaultValues(这一点,R.xml preferences,假的。);
在应用程序的启动活动的的onCreate()
功能为用户启动首次应用程序尽快应用所有的默认值。
The PreferenceFragment preferences are not being added to my SharedPreference Map until after I load the preference fragment.
Is this the intended behavior of the PreferenceFragment?
If so, what is the best way to apply all of the defaults specified in
preferences.xml
to the SharedPreferences even before the user visits the preference fragment?
You can put PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
in the onCreate()
function of the app's launcher activity to apply all of the defaults as soon as a user launches the app for the first time.
这篇关于preferenceFragement没有设置共享preferences后才preferenceFragment是装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!