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()好。
這可能嗎?
因爲'ActionBar'只存在於Android 3.0+中,所以我需要在2.x上運行。 – ateiob
@ateiob對於2.x及以上您可以使用ActionBarSherlock http://abs.io – eveliotc