Click here to Skip to main content
15,944,832 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the below code which gets executed when I am adding or removing fragments to MainActivity.
Java
getSupportFragmentManager().addOnBackStackChangedListener(
            new FragmentManager.OnBackStackChangedListener() {
                public void onBackStackChanged() {
                   if(getSupportFragmentManager().getBackStackEntryCount() > 1) {
                        getSupportActionBar().setDisplayShowHomeEnabled(true);
                        mDrawerToggle.setDrawerIndicatorEnabled(false);
                        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
                        mDrawerToggle.syncState();
                    }
                    else
                    {
                        getSupportActionBar().setDisplayShowHomeEnabled(true);
                        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
                        mDrawerToggle.setDrawerIndicatorEnabled(true);
                        mDrawerToggle.syncState();
                    }
                }
            });

Everything works good except I run the below code to go home fragment. After I execute the below code, It still shows Arrow Icon instead of hamburger icon.
Java
for(int i = 1; i < fragmentManager.getBackStackEntryCount(); ++i) {
            fragmentManager.popBackStack();
        }


What I have tried:

I even tried to remove all fragments and add the home fragment again to stack. Still the same issue.
Posted
Comments
[no name] 2-Jul-18 8:37am    
The variable name suggests fragmentManager might not be the SupportFragmentManager, is that true?
Yesudass Moses 6-Jul-18 14:44pm    
Its supportFragmentManager. But, does that matter ??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900