简体   繁体   English

右上角的导航抽屉图标显示汉堡图标的后退箭头图标

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

I have Create a new android app with the Navigation Drawer Activity. 我用导航抽屉活动创建了一个新的Android应用程序。 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. 当我执行应用程序时,右上角的图标显示后箭头,但它必须是3行的图标。

The icon R.drawable.ic_drawer is this 图标R.drawable.ic_drawer就是这个

在此输入图像描述

In NavigationDrawerFragment class. 在NavigationDrawerFragment类中。

// 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. 选择后,Icon也是一样的。

在此输入图像描述

how do i change it now ? 我现在该如何改变它?

Hope this helps, I solved the above problem this way. 希望这有帮助,我用这种方式解决了上述问题。 @shkschneider is right. @shkschneider是对的。 To make your code work import android.support.v7.app.ActionBarDrawerToggle 要使代码工作,请导入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();
            }
        };

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM