I want to remove navigation drawer when new fragment replaced?

I want remove navigation drawer when new fragment replaced like in gmail app when you open mail from inbox navigation drawer does not appeared instead of back button appeared.

Thank you in advance. Please help me.

-------------Problems Reply------------

In the onCreateView method of the fragment (from which you want to replace the navigation menu icon with a back icon), just add this line:

getActionBar().setDisplayHomeAsUpEnabled(true);

and add this overridden method out of the onCreateView method:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
//do what you want when back arrow is pressed
return true;
}
return super.onOptionsItemSelected(item);
}

Just to let you know: In gmail App though the Hamburger icon is replaced with a back arrow when you open an Email, but the navigation drawer is still there. You can swipe from left to right and find that navigation drawer comes up. In the above method you can get this functionality too.

Category:android Views:5 Time:2017-09-02

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.120 (s). 10 q(s)