【发布时间】:2015-02-22 03:42:28
【问题描述】:
我一直致力于为 Android API 21 升级我的应用程序,并且主要使用支持库 v7。但是,由于这些更改,导航抽屉指示器(汉堡菜单按钮)不再显示。
以前是在 ActionBarDrawerToggle() 方法中设置指示器图标,但在 support lib v7.0 中不再是这种情况。
还有另一个版本的 ActionBarDrawerToggle() 采用 ToolBar 对象。除了操作栏之外,我是否必须有一个工具栏才能恢复抽屉指示器?
还有什么办法?
这是我的操作栏代码。
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
// ActionBarDrawerToggle ties together the the proper interactions
// between the sliding drawer and the action bar app icon
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) {
getSupportActionBar().setTitle(mTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
public void onDrawerOpened(View drawerView) {
getSupportActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);
【问题讨论】:
标签: android android-actionbar navigation-drawer