Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no resource found that matches the given name Theme.Sherlock.Dialog

Android 2.3.3

I have searched SO for a solution, but I couldn't understand the solutions given. If someone can explain in a simple way on how to get rid of this error, I would be thankful.

I am using ActionBarSherlock in my application. My basic theme, Theme.Sherlock.Light, works fine with all the activities. For one activity, I want my activity to look like a dialog and hence I wanted to use Theme.Sherlock.Dialog.

Here is my manifest file's declaration.

<activity
    android:name="com.xxx.xx.x.Activity"
     android:theme="@style/Theme.Sherlock.Dialog" >
</activity>

But I get the following error in my XML : error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.Sherlock.Dialog').. Why am I getting this? What should I do, to remove this?

like image 623
Vamsi Challa Avatar asked May 16 '13 11:05

Vamsi Challa


3 Answers

Dialog themes in ActionBarSherlock were removed by JakeWharton over four months ago.

https://github.com/JakeWharton/ActionBarSherlock/commit/601bde214b56b8fad0b4fc5aaed5af0b531b6135

Just use @android:style/Theme.Dialog and extend Activity instead of SherlockActivity. ActionBarSherlock doesn't do anything for dialogs and it will just complain if you're not using one if its themes.

like image 137
Austin B Avatar answered Nov 13 '22 09:11

Austin B


--- res/values-v14/abs__themes.xml
+++ res/values-v14/abs__themes.xml
@@ -26,9 +26,4 @@
       <item name="android:windowActionBar">false</item>
       <item name="android:windowNoTitle">true</item>
     </style>
+
+    <style name="Theme.Sherlock.Dialog" parent="android:Theme.Holo.Dialog">
+    </style>
+    <style name="Theme.Sherlock.Light.Dialog" parent="android:Theme.Holo.Light.Dialog">
+    </style>
 </resources>
like image 26
user1837311 Avatar answered Nov 13 '22 10:11

user1837311


Theme.Sherlock.Dialog is not supported anymore. I use following approach to style my dialogs in DialogFragment. You can check my dialog templates.

public Dialog onCreateDialog(Bundle savedInstanceState)
{
    ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), getTheme(true));
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    ...
    return builder.create();
}

private int getTheme(boolean light)
{
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH)
    {
        return light ? android.R.style.Theme_DeviceDefault_Light_Dialog : android.R.style.Theme_DeviceDefault_Dialog;
    }
    else if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
    {
        return light ? android.R.style.Theme_Holo_Light_Dialog : android.R.style.Theme_Holo_Dialog;
    }
    else
    {
        return android.R.style.Theme_Dialog;
    }
}
like image 38
petrnohejl Avatar answered Nov 13 '22 10:11

petrnohejl