将
mDrawerLayout.addDrawerListener(new DrawerLayout.DrawerListener()
替换为
mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle
DrawerLayout mDrawerLayout=findViewById(R.id.drawerLayout);
mDrawerLayout.addDrawerListener(new ActionBarDrawerToggle(this,mDrawerLayout,R.string.app_name,R.string.app_name){
@Override
public void syncState() {
super.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}
@Override
public void setHomeAsUpIndicator(Drawable indicator) {
super.setHomeAsUpIndicator(indicator);
}
@Override
public void setHomeAsUpIndicator(int resId) {
super.setHomeAsUpIndicator(resId);
}
@Override
public boolean isDrawerIndicatorEnabled() {
return super.isDrawerIndicatorEnabled();
}
@Override
public void setDrawerIndicatorEnabled(boolean enable) {
super.setDrawerIndicatorEnabled(enable);
}
@NonNull
@Override
public DrawerArrowDrawable getDrawerArrowDrawable() {
return super.getDrawerArrowDrawable();
}
@Override
public void setDrawerArrowDrawable(@NonNull DrawerArrowDrawable drawable) {
super.setDrawerArrowDrawable(drawable);
}
@Override
public void setDrawerSlideAnimationEnabled(boolean enabled) {
super.setDrawerSlideAnimationEnabled(enabled);
}
@Override
public boolean isDrawerSlideAnimationEnabled() {
return super.isDrawerSlideAnimationEnabled();
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset);
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerStateChanged(int newState) {
super.onDrawerStateChanged(newState);
}
@Override
public View.OnClickListener getToolbarNavigationClickListener() {
return super.getToolbarNavigationClickListener();
}
@Override
public void setToolbarNavigationClickListener(View.OnClickListener onToolbarNavigationClickListener) {
super.setToolbarNavigationClickListener(onToolbarNavigationClickListener);
}
});