Sudhir Singh Khanger
Sudhir Singh Khanger

Reputation: 1628

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.

Upvotes: 4

Views: 1655

Answers (3)

Matan Levi
Matan Levi

Reputation: 1

I came across this issue as well.

The solution is remove the style tag from the manifest.xml (android:theme="@style/AppTheme").

It will use the holo theme, but with the Action Bar.

Upvotes: 0

kyster4
kyster4

Reputation: 1

I also had that problem I moved the whole line (android:theme="@style/AppTheme) and its works! The theme is a dark theme which looks better.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006744

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

Upvotes: 7

Related Questions