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">