I'm trying to make the title in my ActionBar bold, I think I have all the necessary styles, but it's crashing with this error message:
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat th
eme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarAc
tivityDelegate.java:111)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBa
rActivityDelegateICS.java:58)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.j
ava:98)
at com.whatspoppin.android.whatspoppin.TestActivity.onCreate(TestActivit
y.java:58)
values->styles.xml:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
<item name="actionBarStyle">@style/MyTheme.MyActionBar</item>
</style>
<style name="MyTheme.MyActionBar" parent="@style/Widget.AppCompat.Base.ActionBar">
<item name="titleTextStyle">@style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textStyle">bold</item>
</style>
And in my manifest:
<activity
android:theme="@style/AppTheme"
android:name=".TestActivity"
android:screenOrientation="portrait"
android:label="Example">
</activity>
So it's telling me I'm not using a Theme.AppCompat theme or descendant, but my AppTheme's parent is AppBaseTheme and it's parent is Theme.AppCompat.Light.DarkActionBar. So why is it complaining about this?
Full error:
ng.RuntimeException: Unable to start activity ComponentInfo{com.whatspoppin.andr
oid.whatspoppin/com.whatspoppin.android.whatspoppin.TestActivity}: java.lang.Ill
egalStateException: You need to use a Theme.AppCompat theme (or descendant) with
this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2
230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit
.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat th
eme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarAc
tivityDelegate.java:111)
at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBa
rActivityDelegateICS.java:58)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.j
ava:98)
at com.whatspoppin.android.whatspoppin.TestActivity.onCreate(TestActivit
y.java:58)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java
:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2144)
... 11 more
Edit Again: Sorry, the error has gone away. However, my title is still not bold. This is all I have:
values
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
<item name="actionBarStyle">@style/MyTheme.MyActionBar</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="MyTheme.MyActionBar" parent="@style/Widget.AppCompat.Base.ActionBar">
<item name="titleTextStyle">@style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textStyle">bold</item>
</style>
values-v11:
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 11 theme customizations can go here. -->
<item name="android:actionBarStyle">@style/MyTheme.MyActionBar</item>
</style>
<style name="MyTheme.MyActionBar" parent="@style/Widget.AppCompat.Base.ActionBar">
<item name="android:titleTextStyle">@style/MyTheme.MyActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.MyActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textStyle">bold</item>
</style>
values-v14:
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>