Navigation Drawer icon on the top right is showing Back arrow icon insted of Hamburger icon

孤者浪人 提交于 2019-12-09 16:47:03

问题


I have Create a new android app with the Navigation Drawer Activity. When i execute the app, the icon on the right corner is showing the back Arrow but it has to be the 3 line's icon.

The icon R.drawable.ic_drawer is this

In NavigationDrawerFragment class.

// ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    ) 

When i execute the App i'm getting Arrow icon on the right.

After the selection also the Icon is same.

how do i change it now ?


回答1:


Hope this helps, I solved the above problem this way. @shkschneider is right. To make your code work import android.support.v7.app.ActionBarDrawerToggle

mDrawerToggle = new ActionBarDrawerToggle(this,
                mDrawerLayout,
                R.string.drawer_open,
                R.string.drawer_close){

            @Override
            public void onDrawerClosed(View drawerView) {
                getSupportActionBar().setTitle(mTitle);
                invalidateOptionsMenu();
            }

            @Override
            public void onDrawerOpened(View drawerView) {
                getSupportActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu();
            }
        };



回答2:


Sorry I'm little late but this might help other people also.

You just need to add the below line and it will work fine. :)

mDrawerToggle.setDrawerIndicatorEnabled(false);


来源:https://stackoverflow.com/questions/30071267/navigation-drawer-icon-on-the-top-right-is-showing-back-arrow-icon-insted-of-ham

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!