我试图在我的应用程序中实现 android.support.v4.app.ActionBarDrawerToggle;由于该类已被弃用。
该类已经被废弃,请使用 support-v7-appcompat 中的 ActionBarDrawerToggle。
我已经转换到了 android.support.v7.app.ActionBarDrawerToggle。
在此之前,我的调用构造函数的方式如下:
mDrawerToggle = new ActionBarDrawerToggle(
this, /* host Activity */
mDrawerLayout, /* DrawerLayout object */
R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
R.string.drawer_open, /* "open drawer" description for accessibility */
R.string.drawer_close /* "close drawer" description for accessibility */
){
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
但是当我切换到更新的v7支持库后,我收到了错误提示。
"ActionBarDrawerToggle() in ActionBarDrawerToggle cannot be applied to:
toolbar: android.support.v7.widget.Toolbar
Actual arguments: R.drawable.ic_drawer (int)"
显然我没有在构造函数中引入一个正确的工具栏,但我不确定理解两个冲突参数之间的区别。我该如何获取所需的工具栏?