ActionBarDrawerToggle No Suitable Constructor Drawable

后端 未结 2 845
旧巷少年郎
旧巷少年郎 2020-12-16 07:40

I have simple code to create simple navigation drawer, but when i declare parameter for ActionBarDrawerToggle it\'s say that drawable icon cannot be applied...

Gradl

相关标签:
2条回答
  • 2020-12-16 08:33

    There are two ActionBarDrawerToggle classes. The support.v4's and the support.v7's. Then, it is very cofusing, the v7's constructor methods are different from v4's.

    You may fix it simply by removing the third argument drawerImageRes.

    drawerListener = new ActionBarDrawerToggle(
        this,
        drawerLayout,
        // R.drawable.ic_drawer, <== delete this argument
        R.string.drawer_open,
        R.string.drawer_close
        ) {
    
        @Override
        public void onDrawerOpened(View drawerView) {
            Toast.makeText(MainActivity.this, "Drawer Opened",
                    Toast.LENGTH_SHORT).show();
        }
    
        @Override
        public void onDrawerClosed(View drawerView) {
            Toast.makeText(MainActivity.this, "Drawer Closed",
                    Toast.LENGTH_SHORT).show();
        }
    };
    
    0 讨论(0)
  • 2020-12-16 08:35

    Change

    import android.support.v4.app.ActionBarDrawerToggle; 
    

    to

    import android.support.v7.app.ActionBarDrawerToggle;
    
    0 讨论(0)
提交回复
热议问题