切换活动时不会出现Android工具栏后退图标

时间:2014-12-13 17:05:21

标签: android android-actionbar

我已经实现了一个自定义工具栏并将其设置为操作栏。

      mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        mDrawerLayout = (android.support.v4.widget.DrawerLayout) 
        findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(
                        this,  mDrawerLayout, mToolbar,
                        R.string.drawer_open,R.string.drawer_close
        ){
                public void onDrawerClosed(View view)
                {super.onDrawerClosed(view);
                    invalidateOptionsMenu();
                    syncState();
                }

     public void onDrawerOpened(View drawerView)
           {super.onDrawerOpened(drawerView);
                    invalidateOptionsMenu();
                    syncState();
            } };
     mDrawerLayout.setDrawerListener(mDrawerToggle); 
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mDrawerToggle.syncState();

但是当用新片段替换当前片段时,汉堡包图标不会变为后退箭头。但是当切换到新活动时,后退箭头正确。有谁知道这里缺少什么?

任何帮助表示感谢。

1 个答案:

答案 0 :(得分:1)

相关问题