0

I am getting a weird problem since 3 days. I searched a lot but was unable to point out my problem.

This is my setup method inside navigatonDrawer class which I had called from the MainActivity.

    public void setUp(DrawerLayout navDrawer, final Toolbar toolbar) {
        mDrawerLayout = navDrawer;
        mDrawerToggle = new ActionBarDrawerToggle(getActivity(), navDrawer, R.string.open, R.string.close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            title= (String) toolbar.getTitle();
            toolbar.setTitle("Menu");
            getActivity().invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if(toolbar.getTitle()=="Menu"){
                toolbar.setTitle(title);
            }
            getActivity().invalidateOptionsMenu();
        }

    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    mDrawerLayout.post(new Runnable() {

        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });
}

My hamburger icon runs with charming animation but on clicking the icon neither it opens the drawer nor it closes it when it's open.

Please guide me. Thanks in advance.

Youngjae
  • 24,352
  • 18
  • 113
  • 198
Aawaz Gyawali
  • 3,244
  • 5
  • 28
  • 48
  • 3
    Well, for starters, `toolbar.getTitle()=="Menu"` will not do what you think it does. Read up on [how to do string comparisons in Java](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java). – MH. Apr 21 '15 at 08:59
  • 1
    @MH. Thanks for your suggestion. I will definitely edit that to .equals() as mentioned on your given link. – Aawaz Gyawali Apr 21 '15 at 09:03

0 Answers0