gpt4 book ai didi

android - requestWindowFeature(Window.FEATURE_NO_TITLE) 异常

转载 作者:太空狗 更新时间:2023-10-29 15:53:33 25 4
gpt4 key购买 nike

当用户点击“开始”按钮时,我正在设置一个特定的 Activity 全屏。

在这种情况下,showStopButton() 被调用。

运行良好。但是如果我插入

 requestWindowFeature(Window.FEATURE_NO_TITLE); 

然后它崩溃了,说明应该在添加内容之前调用它。

我应该如何处理它以将 NO_TITLE 设置为 FULL_SCREEN

    private void showStopButton(){

// requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().findViewById(android.R.id.content).requestLayout();

// handle element visibility
((Button)findViewById(R.id.stopButton)).setEnabled(false);
((Button)findViewById(R.id.startButton)).setVisibility(View.GONE);
((Button)findViewById(R.id.stopButton)).setVisibility(View.VISIBLE);
((SeekBar)findViewById(R.id.seekBar1)).setVisibility(View.VISIBLE);
((Button)findViewById(R.id.resetButton)).setVisibility(View.GONE);
((Button)findViewById(R.id.saveButton)).setVisibility(View.GONE);
}

当开始按钮重新显示时,我有相反的过程,它运行正常在这种情况下,我删除了全屏模式

     private void showStartButton(){

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().findViewById(android.R.id.content).requestLayout();
....
}

最佳答案

非常简单...我只需要隐藏 ActionBar...然后在返回标准屏幕时显示它...

   private void showStopButton(){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
ActionBar actionBar = getActionBar();
actionBar.hide();
getWindow().findViewById(android.R.id.content).requestLayout();

关于android - requestWindowFeature(Window.FEATURE_NO_TITLE) 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21354365/

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