3

I use a MaterialDrawer from Mike Penz and i faced with problem. I have Activity (AppCompat) and 3 Fragmnts. Activity contain all fragments. In fragment 2 and 3 i enable Back button in OnCreate

((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); 

and in Activity

@Override
    public void onBackPressed() {
        if (drawer.isDrawerOpen())
            drawer.closeDrawer();
        if (getFragmentManager().getBackStackEntryCount() == 1) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(false);
            drawer.getActionBarDrawerToggle().syncState();
            getFragmentManager().popBackStack();
        } else if (getFragmentManager().getBackStackEntryCount() > 0)
            getFragmentManager().popBackStack();
        else
            super.onBackPressed();
    }

When active fragment 2 and 3 click on the Back Button leads to opening Drawer & How can I disable the call Drawer in the 2 and 3 fragment by pressing the button Back?

When I used a standard Drawer I had a theme with ActionBar, there are no such problems.

UPD i need click in Toggle Back Button in Toolbar, no smartphone physical button

abbath0767
  • 946
  • 2
  • 11
  • 31

1 Answers1

1

Change

 if (drawer.isDrawerOpen())
     drawer.closeDrawer();
 if (getFragmentManager().getBackStackEntryCount() == 1) {
     getSupportActionBar().setDisplayHomeAsUpEnabled(false);
     drawer.getActionBarDrawerToggle().syncState();
     getFragmentManager().popBackStack();
 }

To

 if (drawer.isDrawerOpen())
     drawer.closeDrawer();
 else if (getFragmentManager().getBackStackEntryCount() == 1) {
     getSupportActionBar().setDisplayHomeAsUpEnabled(false);
     drawer.getActionBarDrawerToggle().syncState();
     getFragmentManager().popBackStack();
 }

You are good to go

V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50