2016-02-16 124 views
0

首页页面都应该有导航抽屉其他页面没有导航抽屉取出抽屉式导航栏,并要显示操作栏主页按钮代替抽屉式导航

显示了插入符号 - >这样

主页视图看起来像

see here for details

而且fragment看法是这样的:

see here for details Navigation drawer menu items selection snapshot

与开发的应用程序具有导航抽屉,我想隐藏抽屉式导航栏,并显示操作栏主页按钮setHomeAsUpEnabled = true而不是导航抽屉navigation drawer我的主页。

我怎样才能实现这个逻辑到我的应用程序?

请让我知道,如果有人知道这个??

+0

而不是使用片段使用活动并使用自定义工具栏 –

+0

[在使用片段时在Android导航抽屉图像和插入符号之间切换]的可能重复(http://stackoverflow.com/questions/ 17258020 /切换Android之间的导航,抽屉图像和向上时刻care-when-using-fragme) –

回答

0

启用主页后退按钮使用下面的代码。

getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
+0

已经尝试过这段代码。 –

+0

我检查这个片段正常工作,但问题是其他片段有导航抽屉菜单以及如何处理所有片段? –

0

这个创建custome工具栏:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:local="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:minHeight="?attr/actionBarSize" 
    android:background="@mipmap/top_bar_bg" 
    local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    local:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
    /> 

把这个活动

private Toolbar toolbar; 
toolbar = (Toolbar) findViewById(R.id.toolbar); 
setSupportActionBar(toolbar);   getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

把这个清单

<activity 
      android:name=".activity.RegisterActivity" 
      android:label="@string/profile" 
      android:parentActivityName=".activity.HomeActivity" 
      > 

android:name和012替换当前的活动用android:parentActivity替换您的父级活动