Search code examples
androidactionbardrawertoggle

Add NavigationDrawer toggler by replacing back navigation in action bar


I have an activity in my app which is not launcher. I want to add a navigation drawer with toggler. I tried following the instructions here http://developer.android.com/training/implementing-navigation/nav-drawer.html#ActionBarIcon

But my back navigation still shows up (It exits the app as I have added appropriate flags to the intent) How can I show the drawer toggler icon ?

Also android.support.v4.app.ActionBarDrawerToggler is deprecated, what should I use instead ?


Solution

  • for android.support.v4.app.ActionBarDrawerToggler is deprecated to use new one get support library supporv7 appcompact check here https://developer.android.com/intl/es/reference/android/support/v4/app/ActionBarDrawerToggle.html

    and creating Navigation drawer here you get all information http://developer.android.com/intl/es/training/implementing-navigation/nav-drawer.html

    code sample

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                    this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
            drawer.setDrawerListener(toggle);
            toggle.syncState();
    

    use the latest support library you will get done it easily and not use setHomeasUpEnabled(true)