我的项目在 android 4 及更高版本上运行良好,但我想让 id 在旧版本上工作,所以我转向操作栏 sherlock。我实现了库,更改了主题,扩展了 SherlockActivity,但是当我尝试在 2.3 上运行它时,出现以下错误。
12-10 20:08:33.403: E/AndroidRuntime(753): FATAL EXCEPTION: main
12-10 20:08:33.403: E/AndroidRuntime(753): java.lang.NoClassDefFoundError: com.actionbarsherlock.R$styleable
12-10 20:08:33.403: E/AndroidRuntime(753): at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:982)
12-10 20:08:33.403: E/AndroidRuntime(753): at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:899)
12-10 20:08:33.403: E/AndroidRuntime(753): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:833)
12-10 20:08:33.403: E/AndroidRuntime(753): at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:212)
12-10 20:08:33.403: E/AndroidRuntime(753): at org.tracker.pms2.Home.onCreate(Home.java:42)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.os.Handler.dispatchMessage(Handler.java:99)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.os.Looper.loop(Looper.java:123)
12-10 20:08:33.403: E/AndroidRuntime(753): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-10 20:08:33.403: E/AndroidRuntime(753): at java.lang.reflect.Method.invokeNative(Native Method)
12-10 20:08:33.403: E/AndroidRuntime(753): at java.lang.reflect.Method.invoke(Method.java:507)
12-10 20:08:33.403: E/AndroidRuntime(753): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-10 20:08:33.403: E/AndroidRuntime(753): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-10 20:08:33.403: E/AndroidRuntime(753): at dalvik.system.NativeStart.main(Native Method)
当我双击到第 7 行时,它会将我重定向到此
setContentView(R.layout.home);
任何人有任何线索是什么问题?:/
这是清单:
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="15" />
<supports-screens android:resizeable="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true" >
</supports-screens>
<application
android:icon="@drawable/pecal_launcher"
android:label="@string/app_name"
android:theme="@style/MyTheme" >
<activity
android:name=".Home"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
这是我的价值观\风格:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="Theme.Sherlock.Light">
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="android:background">@drawable/background_menu</item>
<item name="background">@drawable/background_menu</item>
<item name="android:titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
<item name="titleTextStyle">@style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="MyTheme.ActionBar.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
</resources>