详细信息:将汉堡图标更改为自定义图标后,单击时没有响应(抽屉打不开)
这是 oncreate 方法的代码片段
@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();
}
更多详情:
汉堡图标确实会发生变化,并且在通过幻灯片打开抽屉时也会响应,但是当我单击自定义图标时,它不会。
删除此行:
drawerToggle.setDrawerIndicatorEnabled(false);