android - androidx.legacy.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。旧版.app.ActionBarDrawerToggle 到 androidx。appcompat .app.ActionBarDrawerToggle,即遗留给appcompat。
另外,请记住将您的工具栏添加为您的第三个参数。
文档可以在这里找到: https ://developer.android.com/reference/androidx/appcompat/app/ActionBarDrawerToggle
推荐阅读
- pdf - SAS,在报告中打印语句
- perl - 将文件命名为当前日期
- mongodb - MongoDB - 当启动 mongodb 时,它使用代码关闭:62
- sql - 如何假设 DATETIME 在我的本地时区,然后转换为 UTC
- go - Golang Dockerfile:无法在 docker build 中找到包但运行正常
- cron - crontab 中的 CAT 命令
- python - 在 Linux 环境中从 Python 创建 Windows 可执行文件的最简单方法
- javascript - RxJS 定时器复位
- javascript - 我怎样才能得到这个论点?
- python - 记录 kwargs 时出现 TypeError