1

I followed this tutorial (github code) with the unique difference that, as the ActionBarActivity appeared as deprecated, I extend Activity and use getActionBar() to get a reference to it. I think the rest of things are exactly as the tutorial, imports too.

It works for me except for one thing. I always see the back arrow icon in (and only in) my MainActivity. I don't want a back arrow in my action bar, I just want the ic_drawer or hamburguer icon to inform the user that options are there. So I don't mind if I can't get the animation between the arrow and the hamburguer icon that shows the tutorial. I just want the hamburguer icon being displayed always there, but now only the arrow icon appears.

I tried several solutions as the ones of this post but none of them worked for me.

My styles.xml looks like this:

 <resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/primary</item>
        <item name="colorPrimaryDark">@color/primaryDark</item>
        <!-- navigation Drawer's -->
        <item name="homeAsUpIndicator">@drawable/ic_drawer</item>
        <item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
    </style>
    </resources>

Note: My ic_drawer icons are inside the drawable-*dpi folders, not inside the drawable folder.

Also used syncState as suggested:

 @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Pass any configuration change to the drawer toggls
        mDrawerToggle.onConfigurationChanged(newConfig);
    }

In my build.gradle:

minSdkVersion 17
targetSdkVersion 22

...

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:appcompat-v7:22.2.0'
}

SOLUTION: I changed my styles.xml for:

<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo">
    <!-- navigation Drawer's -->
    <item name="homeAsUpIndicator">@drawable/ic_drawer</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_drawer</item>
</style>

Also I realized I forgot to include in the Manifest the style I was using:

 <application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme"
    android:debuggable="false">
Cœur
  • 37,241
  • 25
  • 195
  • 267
Ángel Fas
  • 353
  • 1
  • 3
  • 15
  • ActionBarActivity is deprecated. You should use AppCompatActivity instead, and continue using getSupportActionBar() instead of getActionBar() – rhoadster91 Jul 05 '15 at 21:41
  • But I'm not extending ActionBarActivity, I'm extending Activity. Should I extend AppCompatActivity? – Ángel Fas Jul 05 '15 at 22:37
  • Yes as the theme you are using is an AppCompat theme, your Activity should also be an AppCompatActivity. Then use all the support library components like support action bar and support drawer layout – rhoadster91 Jul 06 '15 at 07:39
  • But, let me see if I understood correctly. My minSdkVersion is 17 -the app is targeted to young people and is quite probably they'll not have older devices-, so I guess there's no point in using the appcompat library or theme as all things I use are already supported in Jelly Bean. Am I right? – Ángel Fas Jul 07 '15 at 14:07
  • correct. appcompat themes are meant to work with appcompat components. If you don't want to use support library components, use the regular theme. (i.e. without "appcompat" in its name) – rhoadster91 Jul 07 '15 at 14:12

0 Answers0