user6764634
user6764634

Reputation:

How to open NavigationDrawer with Fab?

I want while click on FAB button it Open Navigation Drawer.

How to do?

Upvotes: 1

Views: 979

Answers (2)

Ganesh Pokale
Ganesh Pokale

Reputation: 1594

mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout);

and add following line in Fab Onclick

mDrawerLayout.openDrawer(Gravity.LEFT);

Upvotes: 1

ZeroOne
ZeroOne

Reputation: 9117

You can take a look at this DrawerLayout

mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout);

FloatingActionButton myFab = (FloatingActionButton) myView.findViewById(R.id.myFAB); 
myFab.setOnClickListener(new View.OnClickListener() { 
    public void onClick(View v) { 
       //if you need open the slide:
       mDrawerLayout.openDrawer(Gravity.LEFT);

       //if you need close the slide
       mDrawerLayout.closeDrawer(Gravity.LEFT);  
    } 
});

Upvotes: 4

Related Questions