Reputation: 5063
In the application I am working with an ActionBar Sherlock
. The error I am getting seems to be very strange as I am using the same theme for 2 other activities in the application.
Manifest:
<activity
android:name=".ABC"
android:label="@string/app_name"
android:theme="@style/transTheme" >
<intent-filter >
<action android:name="com.example.ABC"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".XYZ"
android:label="@string/app_name"
android:theme="@style/transTheme" >
<intent-filter >
<action android:name="com.example.XYZ"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name=".123"
android:label="@string/app_name"
android:theme="@style/transTheme" >
<intent-filter >
<action android:name="com.example.123"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Style:
<!-- Transparent Layout Themeing -->
<style name="transTheme" parent="android:style/Theme.Translucent">
<item name ="android:windowNoTitle">true</item>
<item name ="android:windowContentOverlay">@null</item>
<item name ="android:backgroundDimEnabled">true</item>
<item name ="android:background">@android:color/transparent</item>
</style>
As in the manifest file, activities ABC and XYZ work without errors. I get my error in activity 123.
Error Log:
09-08 10:40:08.446: E/AndroidRuntime(23791): FATAL EXCEPTION: main
09-08 10:40:08.446: E/AndroidRuntime(23791): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vaw.selfhelp/com.vaw.selfhelp.SureSMS}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.os.Handler.dispatchMessage(Handler.java:99)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.os.Looper.loop(Looper.java:130)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread.main(ActivityThread.java:3687)
09-08 10:40:08.446: E/AndroidRuntime(23791): at java.lang.reflect.Method.invokeNative(Native Method)
09-08 10:40:08.446: E/AndroidRuntime(23791): at java.lang.reflect.Method.invoke(Method.java:507)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
09-08 10:40:08.446: E/AndroidRuntime(23791): at dalvik.system.NativeStart.main(Native Method)
09-08 10:40:08.446: E/AndroidRuntime(23791): Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1003)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:915)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:849)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
09-08 10:40:08.446: E/AndroidRuntime(23791): at com.vaw.selfhelp.SureSMS.onCreate(SureSMS.java:29)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-08 10:40:08.446: E/AndroidRuntime(23791): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
09-08 10:40:08.446: E/AndroidRuntime(23791): ... 11 more
SureSMS.java (or 123.java) line 29
setContentView(R.layout.123layout);
I did try using the
setTheme(R.style.transTheme)
in the java class which got rid of the error but this didn't the activity its transparency. The application works fine for devices HoneyComb and above. I am only getting this error on devices below Android 3.0. Please help.
Upvotes: 0
Views: 99
Reputation: 32
Problem is you are not using the theme provided by ActionBarSherlock. You must use Theme.Sherlock or Theme.Sherlock.Light or Theme.Sherlock.Light.DarkActionBar
inorder to the action bar to work.
Option 1:
You can remove all the activity specific theming and add the theme to the application context.
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
Option 2:
You can change the
<activity
android:name=".123"
android:label="@string/app_name"
android:theme="@style/transTheme" >
to
<activity
android:name=".123"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock" >
Option 3:
You can use
<style name="transTheme" parent="android:style/Theme.Sherlock">
instead of using the
<style name="transTheme" parent="android:style/Theme.Translucent">
Upvotes: 1