我想点击FAB按钮时打开导航抽屉。
怎么办?
答案 0 :(得分:3)
您可以查看此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);
}
});
答案 1 :(得分:1)
mDrawerLayout = (DrawerLayout) getView().findViewById(R.id.drawer_layout);
并在Fab Onclick中添加以下行
mDrawerLayout.openDrawer(Gravity.LEFT);