无法在androidx.appcompat.app.ActionBarDrawerToggle中使用操作栏

时间:2019-07-08 13:04:57

标签: android android-actionbar

import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.widget.Toolbar;

mToolbar = (Toolbar) findViewById(R.id.toolBar);
        toolbaTitleTextView = (TextView) findViewById(R.id.toolbaTitleTextView);
        actionBarDrawerToggle = new ActionBarDrawerToggle(
                this,
                mDrawerLayout,
                mToolbar, R.string.application_name,
                R.string.application_name) {
            public void onDrawerClosed(View view) {
                toolbaTitleTextView.setText(mTitle);
                invalidateOptionsMenu();
}

好。很好。

但是在旧项目中,我使用

android.support.v7.app.ActionBar

是否可以将ActionBarDrawerToggleactionbar一起使用?

1 个答案:

答案 0 :(得分:0)

我相信此ActionBarDrawerToggle也将适用于ActionBar

android.support.v7.app.ActionBarDrawerToggle中还存在ActionBarDrawerToggle

我还检查了-ActionBarDrawerToggle构造函数也可以与ActionBar一起使用。

        ActionBar actionBar;
        ...
        ..
        toolbaTitleTextView = (TextView) findViewById(R.id.toolbaTitleTextView);
        actionBarDrawerToggle = new ActionBarDrawerToggle(
                this,
                mDrawerLayout,
                actionBar, R.string.application_name,
                R.string.application_name) {
            public void onDrawerClosed(View view) {
                toolbaTitleTextView.setText(mTitle);
                invalidateOptionsMenu();

让我知道我是否误解了这个问题。

相关问题