我正在尝试使我的应用程序兼容3.0+以上的所有Android版本。我的操作栏在版本4.0+中工作正常,但当我尝试在蜂窝模拟器上运行它时,我当前收到此错误:
04-12 03:28:49.525:E / AndroidRuntime(1447):致命异常:主要 04-12 03:28:49.525:E / AndroidRuntime(1447):java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.chartviewer / com.example.chartviewer.JsonActivity}:java.lang.IllegalStateException:You必须使用Theme.Sherlock,Theme.Sherlock.Light,Theme.Sherlock.Light.DarkActionBar或衍生物。 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread.access $ 500(ActivityThread.java:122) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1024) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.os.Handler.dispatchMessage(Handler.java:99) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.os.Looper.loop(Looper.java:132) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread.main(ActivityThread.java:4123) 04-12 03:28:49.525:E / AndroidRuntime(1447):at java.lang.reflect.Method.invokeNative(Native Method) 04-12 03:28:49.525:E / AndroidRuntime(1447):at java.lang.reflect.Method.invoke(Method.java:491) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:841) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-12 03:28:49.525:E / AndroidRuntime(1447):at dalvik.system.NativeStart.main(Native Method) 04-12 03:28:49.525:E / AndroidRuntime(1447):引起:java.lang.IllegalStateException:您必须使用Theme.Sherlock,Theme.Sherlock.Light,Theme.Sherlock.Light.DarkActionBar或衍生物。 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1003) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:915) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:849) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229) 04-12 03:28:49.525:E / AndroidRuntime(1447):at com.example.chartviewer.JsonActivity.onCreate(JsonActivity.java:88) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.Activity.performCreate(Activity.java:4397) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-12 03:28:49.525:E / AndroidRuntime(1447):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779) 04-12 03:28:49.525:E / AndroidRuntime(1447):... 11更多
这是我的行动条码:
<style name="Theme.mmcv" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_mmcv</item>
<item name="android:actionBarStyle">@style/mmcv_solid_ActionBar</item>
<item name="android:actionBarTabStyle">@style/mmcv_ActionBarTabStyle</item>
</style>
<style name="mmcv_solid_ActionBar" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@drawable/ab_solid_mmcv</item>
<item name="android:backgroundStacked">@drawable/ab_stacked_solid_mmcv</item>
<item name="android:backgroundSplit">@drawable/ab_bottom_solid_mmcv</item>
</style>
<style name="mmcv_ActionBarTabStyle" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_mmcv</item>
</style>
答案 0 :(得分:0)
根据错误消息:
您必须使用Theme.Sherlock,Theme.Sherlock.Light,Theme.Sherlock.Light.DarkActionBar或衍生
而不是您当前的Theme.Holo.Light
我建议查看ActionBarSherlock theming页面或查看Theme generator的结果,以获取相应的ActionBarSherlock属性。