android中的自定义选项卡标题
我在选项卡活动中设置自定义标题,如下所示android中的自定义选项卡标题,android,Android,我在选项卡活动中设置自定义标题,如下所示 boolean customTitleSupported; customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); // customTitleSupported = false; //check for custom title supported feature if(customTitleSupported == t
boolean customTitleSupported;
customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
// customTitleSupported = false;
//check for custom title supported feature
if(customTitleSupported == true) {
customTitleBar();
} else {
requestWindowFeature(Window.FEATURE_LEFT_ICON);
String title = prefManager.getTitle();
setTitle(NAME + " " + title);
}
//Set contentview of activity
setContentView(R.layout.tabactivity);
if(customTitleSupported == false){
setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.logo);
}
一切正常。但当我将CustomTitle Supported设置为FALSE以检查sdk中是否没有自定义标题支持时,它应该调用正常的setTitle()函数。
但是如果我这样做customTitleSupported=false代码>
我得到以下错误
android.util.AndroidRuntimeException: You cannot combine custom titles with other title
features
如果自定义标题不受支持,我不清楚为什么我不能请求其他标题功能。如果我不请求自定义标题,则设置图标和标题的其他部分起作用,但我希望同时处理这两种情况
谢谢您不能将其他标题功能与功能_CUSTOM_title一起使用,并且一旦请求,您不能关闭功能:检查
您只需使用setFeatureInt(intFeatureId,intValue)并在“value”处提供布局资源ID。检查此示例:您不能将其他标题功能与功能\u自定义\u标题一起使用,并且一旦请求,您无法关闭功能:检查
您只需使用setFeatureInt(intFeatureId,intValue)并在“value”处提供布局资源ID。检查此示例:谢谢您的回答。然后,请建议我如果功能自定义标题不受支持该怎么办,如何在标题栏上设置默认标题和图像。谢谢您的回答。然后,请建议我如果功能自定义标题不受支持该怎么办,如何在标题栏上设置默认标题和图像。