点击后导航抽屉上的Android汉堡包图标无响应

时间:2017-01-15 08:23:48

标签: android navigation-drawer drawerlayout android-navigation-drawer drawertoggle

详细信息:将汉堡包图标更改为自定义图标后,单击时不响应(抽屉未打开)

以下是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();


    }

更多详情:

汉堡包图标确实发生变化,并且当通过幻灯片打开抽屉时它也会响应,但是当我点击自定义图标时它不会...

1 个答案:

答案 0 :(得分:0)

删除此行:

drawerToggle.setDrawerIndicatorEnabled(false);