我使用Style Generator来增加我的App风格。但是当我为AppCompat生成样式时,我遇到了问题。
错误:
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x010102ce
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x010102d7
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x010102db
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x010102f3
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x010102f7
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x01010300
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x01010397
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x0101039c
11-29 05:25:04.637: E/ResourceType(27454): Style contains key with bad entry: 0x0101039d
11-29 05:25:04.667: E/AndroidRuntime(27454): FATAL EXCEPTION: main
11-29 05:25:04.667: E/AndroidRuntime(27454): java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.pixells.simuladorbr/br.com.pixells.simuladorbr.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
我只生成了样式,我将所有文件夹复制到我的“res文件夹”并更改清单中的主题,如下所示:
android:theme="@style/Theme.Abar" >
生成的样式是:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Abar" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarItemBackground">@drawable/selectable_background_abar</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Abar</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Abar</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Abar</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Abar</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Abar</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_abar</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_abar</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Abar</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">@style/Theme.Abar.Widget</item>
</style>
<style name="ActionBar.Solid.Abar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/ab_solid_abar</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_abar</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_abar</item>
<item name="android:progressBarStyle">@style/ProgressBar.Abar</item>
</style>
<style name="ActionBar.Transparent.Abar" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">@drawable/ab_transparent_abar</item>
<item name="android:progressBarStyle">@style/ProgressBar.Abar</item>
</style>
<style name="PopupMenu.Abar" parent="@android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">@drawable/menu_dropdown_panel_abar</item>
</style>
<style name="DropDownListView.Abar" parent="@android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_abar</item>
</style>
<style name="ActionBarTabStyle.Abar" parent="@android:style/Widget.Holo.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_abar</item>
</style>
<style name="DropDownNav.Abar" parent="@android:style/Widget.Holo.Spinner">
<item name="android:background">@drawable/spinner_background_ab_abar</item>
<item name="android:popupBackground">@drawable/menu_dropdown_panel_abar</item>
<item name="android:dropDownSelector">@drawable/selectable_background_abar</item>
</style>
<style name="ProgressBar.Abar" parent="@android:style/Widget.Holo.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_abar</item>
</style>
<style name="ActionButton.CloseMode.Abar" parent="@android:style/Widget.Holo.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_abar</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Abar.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Abar</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Abar</item>
</style>
</resources>
答案 0 :(得分:0)
在您的代码中尝试此操作。 改变父母&#34;属性值。
<style name="Theme.Abar" parent="Theme.AppCompat.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_abar</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Abar</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Abar</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Abar</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Abar</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Abar</item>
<item name="android:actionModeBackground">@drawable/cab_background_top_abar</item>
<item name="android:actionModeSplitBackground">@drawable/cab_background_bottom_abar</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Abar</item>
<!-- Light.DarkActionBar specific -->
<item name="android:actionBarWidgetTheme">@style/Theme.Abar.Widget</item>
</style>