我用过
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
从我的应用程序中隐藏标题栏......... 这工作正常,但现在,在相同的活动和相同的布局中,我需要在按下按钮时激活它。我能这样做吗?我已经尝试但返回异常原因:
E/AndroidRuntime(23656): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
我该如何解决这个问题?
答案 0 :(得分:0)
隐藏:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
显示:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
然后每次致电setContentView()