ActionBarCompat:java.lang.IllegalStateException:您需要使用Theme.AppCompat我得到在Android 2.3.5一個(gè)RuntimeException,但我正在用Theme.AppCompat(RES /價(jià)值/的themes.xml)。這是電話:http://www.gsmarena.com/samsung_galaxy_y_s5360-4117.php <!-- res/values/themes.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="@style/Theme.AppCompat">
<item name="actionBarStyle">@style/QueryActionBar</item>
<item name="android:actionBarStyle">@style/QueryActionBar</item>
</style>
<style name="QueryActionBar" parent="@style/Widget.AppCompat.ActionBar">
<item name="background">@color/blueback</item>
<item name="android:background">@color/blueback</item>
<item name="backgroundSplit">@color/blueback</item>
<item name="android:backgroundSplit">@color/blueback</item>
</style>
</resources>這是values-v11的文件。 <!-- res/values-v11/themes.xml -->
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="QueryTheme" parent="@android:style/Theme.Holo">
<!-- Any customizations for your app running on devices with Theme.Holo here -->
</style>
</resources>這是錯(cuò)誤。 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.txt2lrn.www/com.txt2lrn.www.LandingActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)對(duì)不起朋友們,我也確實(shí)在AndroidManifest.xml中定義了android:theme =“@ style / Theme.Styled”。
3 回答

繁華開滿天機(jī)
TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超4個(gè)贊
如果要在MainActivity中擴(kuò)展ActionBarActivity,則還必須在values-v11中更改父主題。
所以values-v11中的style.xml將是 -
<!-- res/values-v11/themes.xml --> <?xml version="1.0" encoding="utf-8"?> <resources> <style name="QueryTheme" parent="@style/Theme.AppCompat"> <!-- Any customizations for your app running on devices with Theme.Holo here --> </style> </resources>
編輯:我建議你停止使用ActionBar并開始使用Android設(shè)計(jì)支持庫中包含的AppBar布局

米琪卡哇伊
TA貢獻(xiàn)1998條經(jīng)驗(yàn) 獲得超6個(gè)贊
檢查并確保您沒有引用theme.styled的其他值文件夾,并且不使用AppCompat主題
即values-v11
文件夾
- 3 回答
- 0 關(guān)注
- 325 瀏覽
添加回答
舉報(bào)
0/150
提交
取消