Question

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

Was it helpful?

Solution

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>

OTHER TIPS

@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!

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" 。

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.

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

}

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.

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

From this:

android:theme="@style/AppTheme">

to this:

android:theme="@style/custom_title">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top