2012-06-28 48 views
5

在我的onCreate()我設置一個進度條如下:結合自定義標題與FEATURE_PROGRESS

getWindow().requestFeature(Window.FEATURE_PROGRESS); 
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON); 

現在,希望以增強標題欄一點點,我想改變它的顏色background。第一步就是要檢查是否支持FEATURE_CUSTOM_TITLE

final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
if (customTitleSupported) { 
    Log.i(TAG, "CUSTOM TITLE SUPPORTED!") 
} 

但只要我稱之爲requestWindowFeature(Window.FEATURE_CUSTOM_TITLE)我得到一個:

AndroidRuntimeException: You cannot combine custom titles with other title features 

(如果設置之前調用此函數沒關係FEATURE_PROGRESS或之後)

任何想法如何work around這?

或者,我會避免custom標題欄,如果我能找到非自定義標題欄的資源ID。有些東西比危險的getParent()好。

這可能嗎?

回答

1

由於documentation says

FEATURE_CUSTOM_TITLE

標誌的自定義標題。您不能將此 功能與其他標題功能結合使用。

你可以做什麼,因爲你提到的是使用自定義標題欄與ProgressBar,here is an example how to accomplish that

另一方面,你爲什麼不使用Action Bar?

+0

因爲'ActionBar'只存在於Android 3.0+中,所以我需要在2.x上運行。 – ateiob

+0

@ateiob對於2.x及以上您可以使用ActionBarSherlock http://abs.io – eveliotc