其他分享
首页 > 其他分享> > Android 4.0和自定义标题栏不起作用

Android 4.0和自定义标题栏不起作用

作者:互联网

我有一个Android 2.3.3的应用程序,我正在设置一些这样的自定义标题:

final boolean customTitleSupported = requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main);

if ( customTitleSupported ) 
  {
     getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar);
  }

myTitleText = (TextView) findViewById(R.id.myTitle);

if ( myTitleText != null ) 
  {
     myTitleText.setText("MDPI - Main");
  }

所有这些行都在onCreate()中写入.

在android 2.3.3中,一切正常.我现在正在尝试为Android 4.0制作相同的应用程序,但我在设置自定义标题栏时遇到问题.我收到了这个错误:

E/AndroidRuntime(4225): Caused by: android.util.AndroidRuntimeException: You cannot combine custom titles with other title features

我需要帮助才能解决此错误.

我的课程定义如下:

MDPIActivity extends Activity implements OnGestureListener, AnimationListener

谢谢.

解决方法:

我通过设置另一个主题来解决这个问题,例如:

机器人:主题= “@安卓风格/ Theme.Black”

在AndroidManiest文件中.

标签:android,android-titlebar
来源: https://codeday.me/bug/20190729/1573837.html