2

I can't seem to get past this error:

android.util.AndroidRuntimeException: You cannot combine custom titles with other title features

I am running API > 14.

Manifest is as follows:

    <activity
        android:name=".activity.ActivityWelcome"
        android:label="@string/app_label_name"
        android:launchMode="singleTask"
        android:clearTaskOnLaunch="true"
        android:theme="@style/My.Theme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

My activity is doing the following:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.welcome);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_main);
    ...

Where R.layout.window_title_main is:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout_title"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:paddingLeft="5dp" >

    <TextView
        android:id="@+id/textview_title"
        android:drawableLeft="@null"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:marqueeRepeatLimit="-1"/>

</LinearLayout>

Why is this not working when it seems to work for others?

HGPB
  • 4,346
  • 8
  • 50
  • 86
  • refer http://stackoverflow.com/a/8634785/603233 – kumar_android Dec 10 '12 at 17:15
  • Possible duplicate of [Try to use Window.FEATURE\_CUSTOM\_TITLE but got Exception:You cannot combine custom titles with other title feature..](http://stackoverflow.com/questions/2686556/try-to-use-window-feature-custom-title-but-got-exceptionyou-cannot-combine-cust) – Code-Apprentice Aug 27 '16 at 19:35

3 Answers3

6

This is the kind of error that will drive you to insanity and beyond.

So I happen to be using Theme.Holo as my parent theme. (The theme that my own theme extends)

The documentation says:

...the action bar is included in all activities that use the Theme.Holo theme (or one of its descendants), which is the default theme when either the targetSdkVersion or minSdkVersion attribute is set to "11" or greater.

http://developer.android.com/guide/topics/ui/actionbar.html#Adding (first paragraph)

Ok, so when I try to go through the process above (my question) I get the error:

You cannot combine custom titles with other title features

Well, that's because, by default action bar is setup already and it won't allow you to use a custom title bar as well.

Documentation reveals that "each activity includes the action bar":

This way, when the application runs on Android 3.0 or greater, the system applies the holographic theme to each activity, and thus, each activity includes the action bar.

So, I will now focus my time on altering the action bar and not the title bar!

HGPB
  • 4,346
  • 8
  • 50
  • 86
2

FEATURE_CUSTOM_TITLE and

<item name="android:windowNoTitle">true</item>

Are mutially exclusive. Remove

<item name="android:windowNoTitle">true</item>

and it will work again.

Bartosz Przybylski
  • 1,628
  • 10
  • 15
0

As a beginner most of the answers didn't help me for my case. So here is my answer.

Go to res/values folder in your android project and check for strings.xml (this file may vary in your case, something like themes.xml)

Inside the file under resource tag check whether you have style tags. If you don't find it, add the code below as mentioned below as a child to resources tag

something like below

<resources>
    <style name="SomeNameHere">
        <item name="android:windowNoTitle">true</item>
    </style>
</resources>

if you already have style tag, just add the code below to your style tag

    <item name="android:windowNoTitle">true</item>
madhu131313
  • 7,003
  • 7
  • 40
  • 53