简体   繁体   中英

Android hamburger icon on navigation drawer does not respond after clicking

Details: After changing the hamburger icon into a custom icon it does not respond on clicking (drawer does not open)

Here is the code snippet for oncreate method

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(contentViewId());
        toolbar = (Toolbar) findViewById(toolbarId());
        setSupportActionBar(toolbar);

        if (getSupportActionBar() != null) {
            getSupportActionBar().setHomeButtonEnabled(true);
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            if (toolbarTitle() != null || !toolbarTitle().contentEquals(""))
                getSupportActionBar().setTitle(toolbarTitle());
        }

        drawerLayout = (DrawerLayout) findViewById(drawerLayoutId());
        drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.app_name, R.string.app_name);
        drawerLayout.addDrawerListener(drawerToggle);

        navigation = (NavigationView) findViewById(navigationViewId());
        navigation.setNavigationItemSelectedListener(this);
        navigation.getMenu().findItem(selectedMenuItem()).setChecked(true);


       drawerToggle.setDrawerIndicatorEnabled(false);
         drawerToggle.setHomeAsUpIndicator(R.drawable.ic_account_balance_black_24dp); 
        drawerToggle.syncState();


    }

More details:

the hamburger icon do change and also it respond when opening the drawer through slide but when i click the custom icon it does not..

删除此行:

drawerToggle.setDrawerIndicatorEnabled(false);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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