Android系统.ActionBarSherlock.

Ale*_*ndr 2 android actionbarsherlock

尝试从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);
}
Run Code Online (Sandbox Code Playgroud)

清单:

<?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>
Run Code Online (Sandbox Code Playgroud)

ADT不允许用红色x设置android:theme ="@ style/Sherlock".

所以,我在logcat中遇到了exxcted错误:

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
Run Code Online (Sandbox Code Playgroud)

该怎么办?

And*_*res 7

在您的清单中替换:

android:theme="@style/Sherlock.__Theme"
Run Code Online (Sandbox Code Playgroud)

附:

android:theme="@style/Theme.Sherlock"
Run Code Online (Sandbox Code Playgroud)

或任何其他有效主题,例如:

android:theme="@style/Theme.Sherlock.Light"
android:theme="@style/Theme.Sherlock.Light.DarkActionBar"
Run Code Online (Sandbox Code Playgroud)