Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionBar is missing after switching to API21 AppCompat

While working on the Big Nerd Ranch's Criminal Intent project when I updated my AppCompat library from API 19 to API 21 I lost ActionBar. I have tried changing themes around but I can't find a way to get ActionBar.

The full source code is available here.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sudhirkhanger.app.criminalintent" >

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".CrimePagerActivity"
            android:label="@string/app_name" >
        </activity>
    </application>

</manifest>

style.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
    </style>

</resources>

Thanks.

like image 982
Sudhir Singh Khanger Avatar asked Mar 18 '23 11:03

Sudhir Singh Khanger


1 Answers

To use appcompat-v7, you must inherit from ActionBarActivity. CrimeListActivity inherits from SingleFragmentActivity, which in turn inherits from FragmentActivity, not ActionBarActivity.

like image 193
CommonsWare Avatar answered Apr 01 '23 15:04

CommonsWare