尝试从 ActionBarSherlock 开始。下载库。使用最后更新设置 ADT,SDK 相同。
尝试进行简单的活动:
import com.actionbarsherlock.app.SherlockActivity;
import android.os.Bundle;
public class MainActivity extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.alxr.usingsherlocksample"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Sherlock.__Theme" >
<activity
android:name="ru.alxr.usingsherlocksample.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
ADT 不允许将 android:theme="@style/Sherlock" 设置为红色 x。
所以,我在 logcat 中得到了预期的错误:
03-23 21:25:54.437: E/AndroidRuntime(13145): FATAL EXCEPTION: main
03-23 21:25:54.437: E/AndroidRuntime(13145): java.lang.RuntimeException: Unable to start activity ComponentInfo{ru.alxr.usingsherlocksample/ru.alxr.usingsherlocksample.MainActivity}: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.os.Looper.loop(Looper.java:130)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-23 21:25:54.437: E/AndroidRuntime(13145): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 21:25:54.437: E/AndroidRuntime(13145): at java.lang.reflect.Method.invoke(Method.java:507)
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
03-23 21:25:54.437: E/AndroidRuntime(13145): at dalvik.system.NativeStart.main(Native Method)
03-23 21:25:54.437: E/AndroidRuntime(13145): Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.actionbarsherlock.internal.ActionBarSherlockCompat.generateLayout(ActionBarSherlockCompat.java:1003)
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.actionbarsherlock.internal.ActionBarSherlockCompat.installDecor(ActionBarSherlockCompat.java:915)
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:849)
03-23 21:25:54.437: E/AndroidRuntime(13145): at com.actionbarsherlock.app.SherlockActivity.setContentView(SherlockActivity.java:229)
03-23 21:25:54.437: E/AndroidRuntime(13145): at ru.alxr.usingsherlocksample.MainActivity.onCreate(MainActivity.java:13)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-23 21:25:54.437: E/AndroidRuntime(13145): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
03-23 21:25:54.437: E/AndroidRuntime(13145): ... 11 more
该怎么办?