'Activity doesn't inherit parent style

I am converting my app from using ActionBarSherlock to AppCompat. My activities that extend AppCompatActivity don't appear to be inheriting the parent style by default. To explain:

This is styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

</resources>

This is how the class ChooseFunction is declared:

public class ChooseFunction extends AppCompatActivity
{
...
}

This is part of AndroidManifest.xml (some activities removed):

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.enborne.spine"
    android:versionCode="19"
    android:versionName="2.3" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="21" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Spine"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".LoadData"
            android:label="@string/loading_data" />
        <activity android:name=".ChooseFunction"
            android:theme="@style/Theme.AppCompat.Light.DarkActionBar"/>
        <activity android:name=".DownloadNotams"
            android:label="@string/downloading_notams" />
    </application>

</manifest>

The problem is that if I remove the explicit theme attribute from the ChooseFunction activity in the manifest, I get the error "You need to use a Theme.AppCompat theme (or descendant) with this activity."

Now since AppTheme inherits from Theme.AppCompat.Light.DarkActionBar, and the default theme for the application is AppTheme, I would expect ChooseFunction to use the default, and inherit from the AppCompat theme.

I must be doing something wrong, but I cannot see what it is. I did not need to specify the theme explicitly when using ActionBarSherlock.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source