2012-07-06 95 views
0

我有一個應用程序,可以在全屏和普通屏幕之間切換以適應特定條件。 我已經成功地完成了這個通知,但是在我將其從全屏恢復到正常屏幕模式後,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); 
} 
+0

張貼一些代碼會有所幫助。 – 2012-07-06 04:17:10

+0

你在哪裏添加了這段代碼? – 2012-07-06 04:25:00

+0

在onresume ....我沒有這個代碼的問題...只是想添加標題欄,當在if循環中的第一個條件執行 – jaisonDavis 2012-07-06 04:31:40

回答

-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"); 
    } 
+0

這段代碼要求我自定義標題欄吧? – jaisonDavis 2012-07-06 04:35:57

+0

你有自定義標題欄的代碼嗎? – jaisonDavis 2012-07-06 04:36:42