【发布时间】:2012-10-31 08:26:12
【问题描述】:
我的一个屏幕上有一个 tabhost,我在同一个屏幕上做了一个自定义标题。现在我想在自定义标题中添加一个按钮,但我收到“您不能将自定义标题与其他标题功能结合起来”错误。我尝试了this 之类的所有情况,但它对我不起作用。
我的代码是:
requestWindowFeature( Window.FEATURE_CUSTOM_TITLE );
setContentView(R.layout.routes);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.customtitle);
super.onCreate(savedInstanceState);
我在其他屏幕上尝试了此代码(这不包括 tabhost),它可以工作。怎么了?有人可以帮帮我吗?
编辑:
<style name="CustomWindowTitleBackground">
<item name="android:background">#084B8A</item>
</style>
<style name="CustomTheme" parent="android:Theme">
<item name="android:windowTitleSize">65dip</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
在我的清单中: android:theme="@style/CustomTheme"
我没有在Java类中写任何代码sn-p。我只是这样声明。也许是不对的?可能吗?
【问题讨论】:
-
你应该在调用 super.onCreate 之后 setContentView
-
无论如何,你应该一直这样做。
标签: android android-layout custom-component