不能将与其他标题功能的自定义标题 [英] You cannot combine custom title with other title features

查看:143
本文介绍了不能将与其他标题功能的自定义标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我使用ActionBarSherlock库。另外我使用的是自定义标题栏。 这里去我的onCreate:

In my application, I'm using ActionBarSherlock library. Also I'm using a custom title bar. Here goes my onCreate:

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


在我styles.mxl


And in my styles.mxl

<style name="MyTheme" parent="Theme.Sherlock">
        <item name="android:background">#ff888888</item>
        <item name="android:windowNoTitle">false</item>
        <item name="android:windowTitleSize">50dp</item>
        <item name="android:windowTitleBackgroundStyle">@style/windowTitleBackgroundStyle</item>
    </style>
<style name="windowTitleBackgroundStyle">  
  <item name="android:background">#00688B</item>                
</style>


在我使用的MyTheme的活动清单文件。


In Manifest file i am using MyTheme for the activity.

android:theme="@style/MyTheme"


这code正确地与更低的Andr​​oid版本的作品(我曾与GB2.3.5测试)。但是,当我与ICS测试,它的崩溃与下面的错误: 你不能将自定义标题与其他标题功能 我在StackOverflow上的讨论又彻底,但未能解决的问题。 解决方案尝试: 1)假 2)有没有价值-V11夹


This code properly works with lower android version (I have tested with GB2.3.5). But when i tested with ICS, its crashing with the Below error: "You cannot combine custom title with other title features" I went thoroughly in StackOVerflow discussions, but unable to resolve the issue. solutions tried: 1) false 2) there is no values-v11 folder

推荐答案

我收到了同样的异常。

I received the same exception.

以下是我发现:在较新版本的Andr​​oid,框架将使用Window.FEATURE_ACTION_BAR功能每当河洛主题选择。该框架抛出异常每当应用程序调用setFeatureInt(Window.FEATURE_CUSTOM_TITLE)和FEATURE_ACTION_BAR已经设置。

Here is what I found: In newer versions of Android, the framework will use the Window.FEATURE_ACTION_BAR feature whenever the Holo theme is selected. The framework throws the exception whenever an app calls setFeatureInt(Window.FEATURE_CUSTOM_TITLE) and FEATURE_ACTION_BAR has already been set.

在我的情况下,在价值观-V11夹中的styles.xml文件被重新定义我的主题,从机器人继承:Theme.Holo。当我试图在安卓3.0或以上版本上运行我的应用程序 - 它崩溃,因为霍洛使用动作条在默认情况下。此修复程序很简单。使用全息当关闭动作条了。下面是修改后的值-V11 \ styles.xml变化:

In my case, the styles.xml file in the values-v11 folder was redefining my theme to inherit from android:Theme.Holo. When I attempted to run my app on a Android 3.0 or above - it crashed because Holo uses the ActionBar by default. The fix was simple. Turn the ActionBar off when using Holo. Here is the revised values-v11\styles.xml changes:

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

这篇关于不能将与其他标题功能的自定义标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆