简体   繁体   中英

androidx.legacy.app.ActionBarDrawerToggle' is deprecated

I use androidx library and i have androidx.legacy.app.ActionBarDrawerToggle' is deprecated error in the following code:

private ActionBarDrawerToggle mDrawerToggle;

mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        // associate Navigation Drawer with ActionBar
        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                R.drawable.ic_drawer, //nav menu toggle icon

How do i suppose to change it? I tried to find a solution but nothing has to do with androidx. I would apriciate an easy explanation as im new in android.

Change androidx. legacy .app.ActionBarDrawerToggle to androidx. appcompat .app.ActionBarDrawerToggle, ie legacy to appcompat.

Also, remember to add your toolbar as your third argument.

Documentation can be found here: https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM