ActionBarDrawerToggle No Suitable Constructor Drawable

可紊 提交于 2019-11-29 02:39:11

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();
    }
};
Roy

Change

import android.support.v4.app.ActionBarDrawerToggle; 

to

import android.support.v7.app.ActionBarDrawerToggle;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!