显示标题栏

时间:2012-07-06 04:14:33

标签: android titlebar

我有一个应用程序可以在特定条件下在全屏和普通屏幕之间切换。                  我已经通过通知成功完成了此操作,但是在我将其从全屏设置回正常屏幕模式后,TITLE BAR仍然保持隐藏状态。所以,如何在隐藏它后显示标题?

编辑:

我遇到了他们制作自定义标题栏并在其可见性之间切换的答案,但这不是我想要的。

CODE:

if(ScreenReceiver.wasScreenOn) {
    Toast toast=Toast.makeText(this, "screen was on", Toast.LENGTH_LONG);
    toast.show();
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.resume);
} else { 
    Toast toast=Toast.makeText(this, "screen was off", Toast.LENGTH_LONG);
    toast.show();
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);  
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    setContentView(R.layout.main);
}

1 个答案:

答案 0 :(得分:-1)

试试这个

 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                              WindowManager.LayoutParams.FLAG_FULLSCREEN);


/// custom tittle bar declaration 
final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

/// custom tittle bar creation ///....
    if (customTitleSupported) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.tittle_bar);
    }
    final TextView myTitleText = (TextView) findViewById(R.id.title_bar);
    if (myTitleText != null) {
        myTitleText.setText("Categories");
    }