gpt4 book ai didi

android - fragment 中的 getDelegate() 方法?

转载 作者:行者123 更新时间:2023-12-04 23:55:19 31 4
gpt4 key购买 nike

我想在android Fragment中开启夜间模式。

代码在 Activity getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO); 中运行良好

但是我们不能在 fragment 中使用相同的代码

这个问题的解决方案是什么?

是否有其他方法可以在 fragment 内打开夜间模式?

Error in the fragment

代码:((AppCompatActivity)getActivity()).getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_YES);

以上代码刷新了fragment和fragment以及父activity

最佳答案

((AppCompatActivity)getActivity()).getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);

关于android - fragment 中的 getDelegate() 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61676041/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com