gpt4 book ai didi

java - AlertDialog 显示 SystemUiVisibility

转载 作者:太空宇宙 更新时间:2023-11-04 12:14:36 25 4
gpt4 key购买 nike

我正在制作一个android游戏,我使用setSystemUiVisibility设置了我的SystemUiVisibility,以不显示顶部栏和其他系统ui,但是现在当你在游戏中死亡时,我想显示一个带有你的分数的AlertDialog。当我显示 AlertDialog 时,它会恢复 SystemUiVisibility,我不希望发生这种情况。有人知道如何解决这个问题吗?这是我现在用于 AlertDialog 的代码:

dlgAlert.setMessage("You lost, you hit the right color " + Points + " times");
dlgAlert.setTitle("You died");
dlgAlert.setPositiveButton("OK", null);
dlgAlert.create().show();

最佳答案

在创建对话框时使其不可聚焦(这样我们就不会触发用户交互),然后在显示后使其可聚焦。

    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

//Show the dialog!
dialog.show();

//Set the dialog to immersive
dialog.getWindow().getDecorView().setSystemUiVisibility(
context.getWindow().getDecorView().getSystemUiVisibility());

//Clear the not focusable flag from the window
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);

关于java - AlertDialog 显示 SystemUiVisibility,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39548222/

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