Closed cj7 closed 9 years ago
Try this answer http://stackoverflow.com/a/26755373/3410697
You will need to call syncState as far as I know
i have write the syncState inside the function. it was like
if (backStackEntryCount == 0) {
mActionBarDrawerToggle.syncState();
}
It able to function when user click the 1st back button. But if user open onbackStack again, the setDisplayHomeAsUpEnabled was unable to work. It still display hamburger icon. Although the backStackEntryCount is more or equal to 1. It feel weird with the code just able work on 1st time.
Please check if your backstack is really getting popped.
Also make sure you're calling ((ActionBarActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
before the syncstate because if you're setting it to true and never turn it back to false you will never get it right the second time you click.
I will create 2 methods to show back button and show drawer button so it can be simpler to other folks.
In the meanwhile check this answer too for a better explanation:
thanks a million kanytu! i was not calling false on setDisplayHomeAsUpEnabled, was searching for about an hour and a half for the solution. Thanks man
I was using replace the container with fragment. I want when replace the fragment, the nav drawer icon from hamburger change to back arrow, when user on back press, the nav icon turn back to hamburger. Below is my code.
It should turn back to hamburger icon when the backstackentrycount less than 1. But it not able to turn back. Is that i miss out any code? Thanks a lot if you can help me.