2

I already tried the answers here, before you double answer and rank down this question: Theme.AppCompat.Light.DarkActionBar - No resource found.

So... I get no compile errors, app runs, but does not load my styled theme which is based on the Appcompat.Light.DarkActionBar, instead it seems to load the device default theme.

Taking a closer look, I noticed the following:

enter image description here

So, I am guessing that Eclipse does not find the Theme.Appcompat.Light.DarkActionBar and loads the device default instead. It also seems not to be the only theme it does not find. I get no errors complaining about resources not found.

Question: How do I get the theme back?

EDIT: I use AppCompat-v7 as a project library and took care to do the loading correctly, followed the steps mentioned in the first line of this question and tried changing everything already. Here follows the styling code, I know it works, because before I reinstalled Eclipse it did work, and was generated by the theme styler generator: http://jgilfelt.github.io/android-actionbarstylegenerator/

<style name="Theme.Example" parent="@style/Theme.AppCompat.Light.DarkActionBar">
    <item name="actionBarItemBackground">@drawable/selectable_background_example</item>
    <item name="popupMenuStyle">@style/PopupMenu.Example</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Example</item>
    <item name="actionBarTabStyle">@style/ActionBarTabStyle.Example</item>
    <item name="actionDropDownStyle">@style/DropDownNav.Example</item>
    <item name="actionBarStyle">@style/ActionBar.Solid.Example</item>
    <item name="actionModeBackground">@drawable/cab_background_top_example</item>
    <item name="actionModeSplitBackground">@drawable/cab_background_bottom_example</item>
    <item name="actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Example</item>

    <!-- Light.DarkActionBar specific -->
    <item name="actionBarWidgetTheme">@style/Theme.Example.Widget</item>
</style>

<style name="ActionBar.Solid.Example" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
    <item name="background">@drawable/ab_solid_example</item>
    <item name="backgroundStacked">@drawable/ab_stacked_solid_example</item>
    <item name="backgroundSplit">@drawable/ab_bottom_solid_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="ActionBar.Transparent.Example" parent="@style/Widget.AppCompat.ActionBar">
    <item name="background">@drawable/ab_transparent_example</item>
    <item name="progressBarStyle">@style/ProgressBar.Example</item>
</style>

<style name="PopupMenu.Example" parent="@style/Widget.AppCompat.PopupMenu">
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
</style>

<style name="DropDownListView.Example" parent="@style/Widget.AppCompat.ListView.DropDown">
    <item name="android:listSelector">@drawable/selectable_background_example</item>
</style>

<style name="ActionBarTabStyle.Example" parent="@style/Widget.AppCompat.ActionBar.TabView">
    <item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>

<style name="DropDownNav.Example" parent="@style/Widget.AppCompat.Spinner.DropDown.ActionBar">
    <item name="android:background">@drawable/spinner_background_ab_example</item>
    <item name="android:popupBackground">@drawable/menu_dropdown_panel_example</item>
    <item name="android:dropDownSelector">@drawable/selectable_background_example</item>
</style>

<style name="ProgressBar.Example" parent="@style/Widget.AppCompat.ProgressBar.Horizontal">
    <item name="android:progressDrawable">@drawable/progress_horizontal_example</item>
</style>

<style name="ActionButton.CloseMode.Example" parent="@style/Widget.AppCompat.ActionButton.CloseMode">
    <item name="android:background">@drawable/btn_cab_done_example</item>
</style>

<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Example.Widget" parent="@style/Theme.AppCompat">
    <item name="popupMenuStyle">@style/PopupMenu.Example</item>
    <item name="dropDownListViewStyle">@style/DropDownListView.Example</item>
</style>

<style name="btnStyleGenoa" parent="@android:style/Widget.Button">
    <item name="android:textSize">15sp</item>
    <item name="android:textStyle">bold</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:gravity">center</item>
    <item name="android:shadowColor">#000000</item>
    <item name="android:shadowDx">1</item>
    <item name="android:shadowDy">1</item>
    <item name="android:shadowRadius">0.6</item>
    <item name="android:background">@drawable/button_selector</item>
    <item name="android:paddingLeft">5dp</item>
</style>

<style name="CustomDialogTheme" parent="">
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:padding">0dp</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    <item name="android:fitsSystemWindows">true</item>
    <item name="android:listSelector">@drawable/list_selector</item>
</style>

Community
  • 1
  • 1
Rodrigo Rutsatz
  • 285
  • 5
  • 11

2 Answers2

0
<style name="Theme.Example" parent="Theme.AppCompat.Light.DarkActionBar">

Remove the "@style/" prefix from all your parent attributes.

Jeffrey Mixon
  • 12,846
  • 4
  • 32
  • 55
  • Tried that! No good... As mentioned and as showed in the picture... Eclipse does not even give me a preview with the Theme.AppCompat, so it is not my styling code guys... I believe at least... – Rodrigo Rutsatz Nov 13 '14 at 00:37
  • Do notice that the preview in the left is not my styled theme, but Theme.AppCompat.Light.DarkActionBar – Rodrigo Rutsatz Nov 13 '14 at 00:38
  • I see that now. Having the @style prefix will definitely cause your theme not to load correctly, even though it won't give a build error. But it should load in the designer. However, are you sure you included the v4 library jar when you created the appcompat project in Eclipse? Did you follow this exactly? https://developer.android.com/tools/support-library/setup.html#libs-with-res – Jeffrey Mixon Nov 13 '14 at 00:53
  • Yes I have :/... Is it relevent what I check in my project (not AppCompat) in the Order and Export tab under Java Build Path? – Rodrigo Rutsatz Nov 13 '14 at 01:48
  • the funny thing is the preview works for android version 3.x.x! But only! The 2.x and above 3 do not work. I checked that I got all SDKs installed correctly for the different android versions! – Rodrigo Rutsatz Nov 13 '14 at 19:31
  • Is this only a designer issue? Does your app actually run correctly? – Jeffrey Mixon Nov 13 '14 at 19:56
  • Yes, it runs normally... only a designer issue... I will reinstall eclipse the jdk and all android sdks to see if it fixes it... – Rodrigo Rutsatz Nov 13 '14 at 23:52
0

Well since there are no many details, I think you might have forgotten that you need to extend ActionBarActivity in each activity.

public class MainActivity extends ActionBarActivity

This video explains it well:

https://www.youtube.com/watch?v=h57QpXp2TRg

Hussein El Feky
  • 6,627
  • 5
  • 44
  • 57
Shivam
  • 457
  • 1
  • 6
  • 15