Idob
Idob

Reputation: 1650

Missing back button after changing to the new materin theme

After changing from the Holo theme to the new material theme (Theme.AppCompat.Light.DarkActionBar), all the back buttons in my action bar in gone.

This is my app which should have a back button:

<activity
        android:name=".ui.LeagueActivity"
        android:label="@string/title_activity_league"
        android:parentActivityName=".ui.LeagueListActivity" >
        <!-- Parent activity meta-data to support 4.0 and lower -->
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value=".ui.LeagueListActivity" />

</activity>

And my app theme:

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

    <!-- App core design -->
    <item name="colorPrimary">@color/green</item>
    <item name="colorPrimaryDark">@color/greenDark</item>
    <item name="colorAccent">@android:color/white</item>

    <item name="android:textColorPrimary">@android:color/white</item>

</style>

Upvotes: 2

Views: 1564

Answers (1)

Shaun
Shaun

Reputation: 865

Add

getSupportActionBar().setDisplayHomeAsUpEnabled(true);

in your activity's onCreate where it needs a back/up to parent button.

This fixed it for me.

Upvotes: 6

Related Questions