希望定制活动页面的Title,onCreate中代码如下:
final Window window = getWindow();
boolean useTitleFeature = false;
if(window.getContainer() == null) {
useTitleFeature = window.requestFeature(Window.FEATURE_CUSTOM_TITLE);
}
SetContentView(Resource.Layout.LiftInspection);
if (useTitleFeature) {
window.setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.inspection_title);
}
在Android2.3上可以正常工作,但在4.0版本上报如下错误:
Cannot Combine Custom Title With Other Title Features
原因是Android认为你已经设置了活动Title,然后又试图合并入自定义的Title。
解决方法很经验主义:
在styles文件中添加一个新的theme比如mytheme,
在AndroidManiest文件中添加如下活动配置项:
android:theme="@android:style/mytheme"
(不要使用AppTheme)