androidx.legacy.app.ActionBarDrawerToggle' 已弃用
androidx.legacy.app.ActionBarDrawerToggle' is deprecated
我使用 androidx 库,但在以下代码中出现 androidx.legacy.app.ActionBarDrawerToggle' is deprecated 错误:
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
我该如何更改它?我试图找到解决方案,但与 androidx 无关。因为我是 android.
的新手,所以我会给出一个简单的解释
将androidx.legacy.app.ActionBarDrawerToggle更改为androidx.appcompat.app.ActionBarDrawerToggle,即legacy为appcompat .
此外,请记住将您的工具栏添加为您的第三个参数。
可在此处找到文档:
https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle
我使用 androidx 库,但在以下代码中出现 androidx.legacy.app.ActionBarDrawerToggle' is deprecated 错误:
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
我该如何更改它?我试图找到解决方案,但与 androidx 无关。因为我是 android.
的新手,所以我会给出一个简单的解释将androidx.legacy.app.ActionBarDrawerToggle更改为androidx.appcompat.app.ActionBarDrawerToggle,即legacy为appcompat .
此外,请记住将您的工具栏添加为您的第三个参数。
可在此处找到文档: https://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle