运行项目时,有时LogCat报错:AndroidRuntimeException: You cannot combine custom titles with other title feature


网上说,去掉AndroidManifest.xmlActivity的android:theme="@android:style/Theme.NoTitleBar.Fullscreen"属性。但我看AndroidManifest.xml根本没有设这个值
[Java] 纯文本查看 复制代码 ?
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 <application android:allowBackup= "true" android:icon= "@drawable/ic_launcher" android:label= "@string/app_name" android:theme= "@style/TitleBarStyle" > <activity android:name= "com.example.b.MainActivity" android:label= "@string/app_name" > <intent-filter> <action android:name= "android.intent.action.MAIN" /> <category android:name= "android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>



有可能是@style/AppTheme里面设了这个值吧?于是我再看values/styles.xml文件
Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature_第1张图片

4.0 即API 14,AppBaseTheme应该在values-v14/style.xml里面的


于是我再去看android:Theme.Holo.Light.DarkActionBar


<style name="Theme.Holo.Light.DarkActionBar">里面没有关于类似<style name="windowNoTitle">的东西
Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature_第2张图片

<style name="Theme.Holo.Light">代码
Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature_第3张图片

太多东西了{:soso_e117:},他们引用的东西也不尽相同.....


解决方法:

后来,我直接在AndroidManifest.xml中,将android:theme="@style/AppTheme"直接改成android:theme="@style/android:Theme.Light"(就是不继承API 14中的Theme,用回API 11前的Theme)

或者,删除values-v11values-v14里面的styles.xml

Android 4.0后,自定义Title报错 You cannot combine custom titles with other title feature_第4张图片
让系统自动调用values/styles.xml


由于API-11的<style name="Theme.Holo.Light">API-14<style name="Theme.Holo.Light.DarkActionBar">跟API之前版本的<style name="Theme.Light">代码太多不同了,所以就我也不明白到底哪里出了问题


看到别人博客上还有一个解决的方案:

在style.xml中修改加入这句“<item name="android:windowActionBar">false</item>

[html] view plain copy
  1. <stylename="AppTheme"parent="AppBaseTheme">
  2. <!--AllcustomizationsthatareNOTspecifictoaparticularAPI-levelcangohere.-->
  3. <itemname="android:windowActionBar">false</item>
  4. </style>

更多相关文章

  1. 2013.04.03——— android 图片缓存之二LruCache介绍
  2. Android利用Matrix简单处理图片
  3. android带有文字的图片按钮的两种实现方式
  4. 演化理解 Android 异步加载图片
  5. Android布局的一些属性和开关、创建log图片
  6. Android WebView实现选择本地图片拍照功能
  7. 很实用的android压缩图片的算法
  8. android imageView 图片显示方式属性

随机推荐

  1. android生命周期(详细总结)
  2. android:onClick都做了什么
  3. Android 4.0冰淇淋三明治SDK怎么下载
  4. android bluetooth
  5. android:fastScrollEnabled和android:dra
  6. android 图片浏览功能 图片放大缩小 使用
  7. Android中的文本框,图片以及点击事件的设
  8. Android取消EditText自动默认获取焦点行
  9. AutoCompleteTextView(自动完成文本框)
  10. textView 属性总结