Note that there are some explanatory texts on larger screens.

plurals
  1. POHow set Theme in main activity api 7?
    primarykey
    data
    text
    <p>I offer my users a light and dark option for theming.</p> <p>The error in the Log:</p> <blockquote> <p>Caused by: <code>java.lang.IllegalStateException</code>: You must use <code>Theme.Sherlock</code>, <code>Theme.Sherlock.Light</code>, <code>Theme.Sherlock.Light.DarkActionBar</code>, or a derivative.</p> </blockquote> <p>The error occurs in <code>setContentView(R.layout.activity_main);</code> in the MainActivity.</p> <p>MainActivity </p> <pre><code>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); </code></pre> <p>I did not add something in the manifest, because the themes should be changed dynamically AndroidManifest.xml</p> <pre><code>&lt;uses-sdk android:minSdkVersion="7" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:name="com.belasheuski.activities.MyApplication" &gt; &lt;activity android:name="com.belasheuski.activities.MainActivity" android:label="@string/name_main" android:screenOrientation="portrait" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>This error occurs on API 7. On API 15 all works very well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload