2015-05-06 65 views
7

我已创建一个新的导航抽屉活动的Android应用程序。 当我执行应用程序时,右上角的图标显示后退箭头,但它必须是3行的图标。导航右上角的抽屉图标显示后退箭头图标insted汉堡图标

图标R.drawable.ic_drawer是本

enter image description here

在NavigationDrawerFragment类。

// ActionBarDrawerToggle ties together the the proper interactions 
    // between the navigation drawer and the action bar app icon. 
    mDrawerToggle = new ActionBarDrawerToggle(
      getActivity(),     /* host Activity */ 
      mDrawerLayout,     /* DrawerLayout object */ 
      R.drawable.ic_drawer,    /* nav drawer image to replace 'Up' caret */ 
      R.string.navigation_drawer_open, /* "open drawer" description for accessibility */ 
      R.string.navigation_drawer_close /* "close drawer" description for accessibility */ 
    ) 

当我执行应用程序,我得到右侧的箭头图标。

enter image description here

选择后也图标是一样的。

enter image description here

我现在该如何改变呢?

+3

当您从列表中选择任何项目时,它将变回汉堡包。 –

+3

它是'android.support.v4.app.ActionBarDrawerToggle'还是'android.support.v7.app.ActionBarDrawerToggle'?第一个被弃用。否则,对我来说,这似乎是正常的行为,因为它关闭时会恢复到原来的形状。 – shkschneider

+0

这是一个适当的状态,抽屉是开放的。关闭它(通过选择一个项目),看看它是否改变为汉堡。此外,我认为它是'左上角'而不是'右上角' – Skynet

回答

1

希望这有助于我通过这种方式解决了上述问题。 @shkschneider是对的。为了使您的代码工作进口android.support.v7.app.ActionBarDrawerToggle

mDrawerToggle = new ActionBarDrawerToggle(this, 
       mDrawerLayout, 
       R.string.drawer_open, 
       R.string.drawer_close){ 

      @Override 
      public void onDrawerClosed(View drawerView) { 
       getSupportActionBar().setTitle(mTitle); 
       invalidateOptionsMenu(); 
      } 

      @Override 
      public void onDrawerOpened(View drawerView) { 
       getSupportActionBar().setTitle(mDrawerTitle); 
       invalidateOptionsMenu(); 
      } 
     }; 
0

对不起,我迟到了,但这可能也帮助其他人。

你只需要添加下面的行,它会正常工作。 :)

mDrawerToggle.setDrawerIndicatorEnabled(false);