Android - The constructor ActionBarDrawerToggle is undefined

后端 未结 2 1793
星月不相逢
星月不相逢 2021-01-16 13:08

I used this code in my oncreate function to open the navigation drawer by pressing the app icon.

ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerTog         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-16 13:17

    Just to echo @CommonsWare answer. Instead of findViewById(R.id.left_drawer) just do R.id.left_drawer

    So the final result would look like this:

    ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(
                    this,                  /* host Activity */
                    R.drawable.ic_drawer,  /* nav drawer icon to replace 'Up' caret */
                    R.string.drawer_open,  /* "open drawer" description */
                    R.string.drawer_close  /* "close drawer" description */
                    )
    

提交回复
热议问题