在main activity API7设置主题

大家好。
本人提供给用户两个主题选择:明、暗。

log报错:

Caused by: java.lang.IllegalStateException: You must use Theme.Sherlock, Theme.Sherlock.Light, Theme.Sherlock.Light.DarkActionBar, or a derivative.

错误是出现在setContentView(R.layout.activity_main);这一行。

MainActivity

public class MainActivity extends SherlockFragmentActivity {.....public static int globalTheme;
Context context;
protected void onCreate(Bundle savedInstanceState) {


    context = getApplicationContext();
    mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);

    Editor editor = mySharedPreferences.edit();
    editor.putBoolean("proxy", false);
    editor.commit();

    if (mySharedPreferences.getString(Preferences.PREF_THEME, "1").trim().equals("1"))
        globalTheme = R.style.Sherlock___Theme;
    else
        globalTheme = R.style.Sherlock___Theme_Light;
    setTheme(globalTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

没有在manifest中添加任何东西。因为主题会自动修改。

AndroidManifest.xml

<uses-sdk android:minSdkVersion="7"
   />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:name="com.belasheuski.activities.MyApplication"
     >
    <activity
        android:name="com.belasheuski.activities.MainActivity"
        android:label="@string/name_main"
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

API15中运行的很好,但是API7中就出错了。

你看一下这个回答:“
http://bbs.csdn.net/topics/340230202