版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_29375837/article/details/78697850
/*
用于button的切换事件
*/
/**
* 夜间模式切换
*/
private void isNightMode(){
Boolean isNight = sp.getBoolean("night", false);
if (isNight) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
sp.edit().putBoolean("night", false).commit();
} else {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
sp.edit().putBoolean("night", true).commit();
}
getActivity().recreate();
}