Feature Custom Title: Unable to combine custom headers in API 11 and above

I have a project in which I installed:

  • minSdkversion set to 10
  • MainActivity is TabActivity

The code in the onCreate method is as follows:

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

With the previous settings, everything works well! But if I set minSdkVersion to 11 or higher, this exception will occur:

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

I do not understand why this just changes minSdkVersion. I talk a lot about this problem on this site. I tried setting:

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

Since I use functions that are available only from API 11, I want to set minSdk to 11 before loading the application into the Store. How can i do ?? I need help

Change When using minSdkVersion = 10 and Theme.NoTitleBar in the manifest, the same error occurs. Removing this, everything works as before. Can someone provide a working code (manifest and activity code) to set a custom header when the API is 11 or higher? thanks a lot

+7
source share
6 answers

Fixed by me. I don’t know why, but just adding the β€œsubject” manifest property for each activity declaration, everything works:

From this:

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

For this:

 <activity android:name=".CheckActivity" android:configChanges="orientation" android:screenOrientation="portrait" android:theme="@android:style/Theme" > </activity> 
+37
source

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

Prior to this, you do not need to create Theme.NoTitleBar anywhere, you can directly control it in a .java file. Give me some time, come back!

+3
source

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

Tips: if your project does not have "res / values-v11", then check the project referenced by "lib project".

0
source

Besides the accepted answer, there is another way to solve this problem:

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

Assign the theme attribution to application in the main xml-based document, which should work for all actions.

0
source

This issue occurs when you try to add a custom title bar along with expanding your activity using ActionBarActivity or AppcomActivity . These two activity classes already have a title bar. So, when you try to add your own title bar, there is a conflict in which the title bar is used - your custom or the one provided by the activity.

To solve this problem, simply increase your activity on an Activity that has no predefined headers, so yours will be accepted without any conflicts.

 public void MyActivy extends Activity { // your code } 
0
source

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

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

Hope this works for you too.

0
source

All Articles