通过替换操作栏中的后退导航来添加导航抽屉切换
Add NavigationDrawer toggler by replacing back navigation in action bar
我的应用程序中有一个 activity 不是启动器。
我想添加一个带切换器的导航抽屉。我尝试按照此处的说明进行操作 http://developer.android.com/training/implementing-navigation/nav-drawer.html#ActionBarIcon
但我的后退导航仍然显示(它退出应用程序,因为我已经为意图添加了适当的标志)
如何显示抽屉开关图标?
另外 android.support.v4.app.ActionBarDrawerToggler 已弃用,我应该用什么代替?
for android.support.v4.app.ActionBarDrawerToggler 已被弃用以使用新的获取支持库 supporv7 appcompact 在此处检查 https://developer.android.com/intl/es/reference/android/support/v4/app/ActionBarDrawerToggle.html
并在此处创建导航抽屉,您将获得所有信息
http://developer.android.com/intl/es/training/implementing-navigation/nav-drawer.html
代码示例
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
使用最新的支持库,您将轻松完成,而不是使用 setHomeasUpEnabled(true)
我的应用程序中有一个 activity 不是启动器。 我想添加一个带切换器的导航抽屉。我尝试按照此处的说明进行操作 http://developer.android.com/training/implementing-navigation/nav-drawer.html#ActionBarIcon
但我的后退导航仍然显示(它退出应用程序,因为我已经为意图添加了适当的标志) 如何显示抽屉开关图标?
另外 android.support.v4.app.ActionBarDrawerToggler 已弃用,我应该用什么代替?
for android.support.v4.app.ActionBarDrawerToggler 已被弃用以使用新的获取支持库 supporv7 appcompact 在此处检查 https://developer.android.com/intl/es/reference/android/support/v4/app/ActionBarDrawerToggle.html
并在此处创建导航抽屉,您将获得所有信息 http://developer.android.com/intl/es/training/implementing-navigation/nav-drawer.html
代码示例
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
使用最新的支持库,您将轻松完成,而不是使用 setHomeasUpEnabled(true)