6
在共享首選項中有一些默認值通常很好。有沒有一種很好的方法來從xml文件或屬性文件初始化它們?尋找最好的方式來做到這一點。謝謝。Android共享首選項初始化
在共享首選項中有一些默認值通常很好。有沒有一種很好的方法來從xml文件或屬性文件初始化它們?尋找最好的方式來做到這一點。謝謝。Android共享首選項初始化
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Make sure default values are applied. In a real app, you would
// want this in a shared function that is used to retrieve the
// SharedPreferences wherever they are needed.
PreferenceManager.setDefaultValues(getActivity(),
R.xml.advanced_preferences, false);
}
[Android的偏好?:如何當用戶不使用偏好屏幕加載默認值]的
可能重複(HTTP ://stackoverflow.com/questions/2691772/android-preferences-how-to-load-the-default-values-when-the-user-hasnt-used-th) – 2014-08-13 09:13:57