You cannot combine custom title with other title features

11,552

Solution 1

I received the same exception.

Here is what I found: In newer versions of Android, the framework will use the Window.FEATURE_ACTION_BAR feature whenever the Holo theme is selected. The framework throws the exception whenever an app calls setFeatureInt(Window.FEATURE_CUSTOM_TITLE) and FEATURE_ACTION_BAR has already been set.

In my case, the styles.xml file in the values-v11 folder was redefining my theme to inherit from android:Theme.Holo. When I attempted to run my app on a Android 3.0 or above - it crashed because Holo uses the ActionBar by default. The fix was simple. Turn the ActionBar off when using Holo. Here is the revised values-v11\styles.xml changes:

<style name="AppBaseTheme" parent="android:Theme.Holo.NoActionBar">
    <!-- API 11 theme customizations can go here. -->
</style>

Solution 2

I had the same problem and solved it:

THE ROOT CAUSE: In the Manifest, I copy pasted this tag by mistake from my splash screen into my activity: @android:style/Theme.NoTitleBar The fatal exception occured when I also requested a FEATURE_CUSTOM_TITLE on my activity, causing the conflict.

SOLUTION: To fix it, I checked these 3 things: 1)OnCreate method:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_login);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_titlebar);

    }

2)INSIDE your manifest.xml: Make sure a line such as these ONLY appears in a splash screen if you have one: android:theme="@android:style/Theme.NoTitleBar REMOVE that line from any other activity if you want a custom Bar.

In the application tag , my only theme tag is this one: android:theme="@style/AppTheme"

In the activity tag, I have no theme tag.

3) Go to your activity's XML layout, and view it in GRAPHIC LAYOUT mode. Maye sure your that the Theme says AppTheme (its the the you put on the manifest) Mine said "No Title", so this was causing the problem.

Share:
11,552

Related videos on Youtube

basu
Author by

basu

Updated on August 03, 2022

Comments

  • basu
    basu over 1 year

    In my application, I'm using ActionBarSherlock library. Also I'm using a custom title bar. Here goes my onCreate:

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main_tab);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);
    

    And in my styles.mxl

    <style name="MyTheme" parent="Theme.Sherlock">
            <item name="android:background">#ff888888</item>
            <item name="android:windowNoTitle">false</item>
            <item name="android:windowTitleSize">50dp</item>
            <item name="android:windowTitleBackgroundStyle">@style/windowTitleBackgroundStyle</item>
        </style>
    <style name="windowTitleBackgroundStyle">  
      <item name="android:background">#00688B</item>                
    </style>
    

    In Manifest file i am using MyTheme for the activity.

    android:theme="@style/MyTheme"
    

    This code properly works with lower android version (I have tested with GB2.3.5). But when i tested with ICS, its crashing with the Below error: "You cannot combine custom title with other title features" I went thoroughly in StackOVerflow discussions, but unable to resolve the issue. solutions tried: 1) false 2) there is no values-v11 folder

  • OferR
    OferR almost 11 years
    Thanks @craigrf It is better to add <item name="android:windowActionBar">false</item> to the style, and not use .NoActionBar, since the latter include <item name="android:windowNoTitle">true</item>