Feature Custom Title: Cannot combine custom titles on API 11 and above
Asked Answered
B

7

7

I have a project in which i setted:

  • minSdkversion setted to 10
  • MainActivity is a TabActivity

Code in onCreate method is this:

super.onCreate(savedInstanceState);

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

With previous settings, all works well! But, if i set minSdkVersion to 11 or above, this exception occurs:

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

I don't understand why happens this just changing minSdkVersion. I red a lot about this problem on this site. I tried setting:

  • Theme.NoTitleBar in main layout and after in Manifest file too
  • I put those 3 lines in all possible positions
  • If i comment first line a NullPointerException occurs when i call something on my TextView reference of my CustomTitle layout
  • I tried setting, in theme.xml file declaration, "windowNoTitle" = true

Since i'm using functions available from API 11 only, i want to set minSdk to 11 before loading App on Store. How can i do ?? I need Help

Edit: With minSdkVersion = 10 and Theme.NoTitleBar in Manifest, same error occurs. Removing it, all works as before. Can anyone provide a working code (manifest and activity code) for setting a custom title when API is 11 or above ? Thx much

Bandstand answered 5/9, 2012 at 11:20 Comment(1)
There is little use in using little used tags, e.g. any tag value other than tag android is not followed by anyone. The reason why nobody answers is presumably because you try to do the exact opposite of what the error suggests.Furrier
B
38

Fixed by my self. I don't know why, but simply adding in manifest file "theme" property for each activity's declaration, all works:

From this:

<activity
        android:name=".CheckActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait"
</activity>

To this:

<activity
        android:name=".CheckActivity"
        android:configChanges="orientation"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme" >
</activity>
Bandstand answered 30/10, 2012 at 11:51 Comment(1)
This worked for me. I just added the android:theme="@andriod:style/Theme" to my activity and it worked. In my case, it was my Bluetooth activity!Chandrachandragupta
P
3

@kinghomer I have tried CUSTOM_TITLE its on 2.2 (API 8) actually. Let me try on API 11 and get back to you!

Before that, you need not make Theme.NoTitleBar anywhere, can be controlled in .java file directly. Give me some time, will be back!

Plumbo answered 24/10, 2012 at 10:6 Comment(3)
What? My code works or yours ? Can you post your testing code please?Bandstand
Unbelievable! I fix it! I simply add, in each activity's declaration in manifest file, "theme" property (before, there wasn't).Bandstand
I tried with that. Still stuck with the same problem. But, this happens only when I try to run it on my GB phone. (Runs fine on the emulator) I'm supporting API levels 8-17.Mixedup
R
0

res/values-v11 defalut use this code :

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

change "android:Theme.Holo.Light" to "@android:style/Theme" will be ok!

tips: if your project no have "res/values-v11", then check your project referenced "lib project" 。

Restoration answered 13/11, 2014 at 8:18 Comment(0)
M
0

Other than the accepted answer ,there is another way to solve this :

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/CustomTheme" >

assign a theme attribution to application in the xml-based mainifest,that should work for all activities.

Maestro answered 22/5, 2015 at 6:15 Comment(0)
T
0

This problem occurs when you try to add a custom title bar along with extending your activity by ActionBarActivity or AppcomActivity. These two activity classes already have title bar defined. So, when you try to add your own custom title bar a conflict arises, which title bar to use - your custom one or the one provided by activity extended.

To solve this issue, just extend your activity by Activity which does not have any predefined title bars, so yours will be accepted without any conflict.

public void MyActivy extends Activity
{

    // your code

}
Thermoelectric answered 1/1, 2016 at 6:1 Comment(0)
M
0

I just added android:theme="@android:style/Theme" in activity in AndroidManifest.xml file and it worked super fine.

<activity
        android:name=".MainActivity"
        android:theme="@android:style/Theme" >
</activity>

Hope this works for you as well.

Mosely answered 14/7, 2017 at 8:24 Comment(0)
B
0

In your AndroidManifest file, use this snippet instead of yours.

From this:

android:theme="@style/AppTheme">

to this:

android:theme="@style/custom_title">
Bifocal answered 21/10, 2018 at 6:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.