1

I faced with a problem. I have MainActivity with Fragment1 and Navigation Drawer. There is a button in Fragment1 that replace Fragment1 and Fragment2. When Im replacing, I want to turn off Navigation Drawer, change Hamburger button to Home button("<"). So I have method changeTbOn in MainActivity and call it in onCreate Fragment2:

((MainActivity)getActivity()).changeTbOn();

My changeTbOn method:

public void changeTbOn(){
       toggle.setDrawerIndicatorEnabled(false);
        toggle.syncState();
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
       drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        setSupportActionBar(toolbar);
    }

When I did it, Navigation Drawer turn off, Hamburger button didnt changes to Home Button, but it works like Home Button. What I do wrong? I want change it to Home Button icon. Help Please!

MrStuff88
  • 327
  • 3
  • 11
  • Add `getSupportActionBar().setIcon(R.drawable.your_home_icon);` I don't know if this is the solution, or the only solution even if it is, mostly just interested if it "fixes" it. I also think there is a `setDisplayShowHomeEnabled(true);` method – zgc7009 Apr 14 '16 at 19:40
  • Now I have Hamburger Button and near my home icon, but I need change HamubrgerButton to home icon.. – MrStuff88 Apr 14 '16 at 19:46
  • Hide your hamburger button and show your home button. They are two different icons and have two different behaviors. – zgc7009 Apr 14 '16 at 19:47

1 Answers1

0

SOLUTION: Add this to my changeTbOn method:

 toggle.setHomeAsUpIndicator(R.drawable.back_icon);
MrStuff88
  • 327
  • 3
  • 11