ActionBarCompat:java.lang.IllegalStateException

ActionBarCompat:java.lang.IllegalStateException:您需要使用Theme.AppCompat

我得到在Android 2.3.5一个RuntimeException,但我正在用Theme.AppCompat(RES /价值/的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>

这是错误。

 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)

对不起朋友们,我也确实在AndroidManifest.xml中定义了android:theme =“@ style / Theme.Styled”。


胡说叔叔
浏览 313回答 3
3回答

繁华开满天机

如果要在MainActivity中扩展ActionBarActivity,则还必须在values-v11中更改父主题。所以values-v11中的style.xml将是 -&nbsp;<!--&nbsp;res/values-v11/themes.xml&nbsp;--> &nbsp;<?xml&nbsp;version="1.0"&nbsp;encoding="utf-8"?> &nbsp;<resources> &nbsp;&nbsp;&nbsp;&nbsp;<style&nbsp;name="QueryTheme"&nbsp;parent="@style/Theme.AppCompat"> &nbsp;&nbsp;&nbsp;&nbsp;<!--&nbsp;Any&nbsp;customizations&nbsp;for&nbsp;your&nbsp;app&nbsp;running&nbsp;on&nbsp;devices&nbsp;with&nbsp;Theme.Holo&nbsp;here&nbsp;--> &nbsp;&nbsp;&nbsp;&nbsp;</style> &nbsp;</resources>编辑:我建议你停止使用ActionBar并开始使用Android设计支持库中包含的AppBar布局

米琪卡哇伊

检查并确保您没有引用theme.styled的其他值文件夹,并且不使用AppCompat主题即values-v11文件夹
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android