2012-06-28 49 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