Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 443
kinghomer Avatar asked Sep 05 '12 11:09

kinghomer


2 Answers

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>
like image 147
kinghomer Avatar answered Oct 07 '22 00:10

kinghomer


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

like image 45
Charan Avatar answered Oct 06 '22 23:10

Charan