Reputation: 513
I used the following library https://github.com/futuresimple/android-floating-action-button and everything works fine.
How do I close the menu automatically after clicking on one of the buttons on the same menu?
Upvotes: 1
Views: 7299
Reputation: 1
FloatingActionMenu fAM = (FloatingActionMenu) findViewById(R.id.fAM_ID);
FloatingActionButton fAB1 = (FloatingActionButton)findViewById(R.id.fAB_ID);
floatingActionButton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Action
Toast.makeText(MainActivity.this, "FAB Click", Toast.LENGTH_SHORT).show();
fAM.collapse();
}
});
Upvotes: 0
Reputation: 8734
Its open-source lib, You can read the source code and find that by your self.
FloatingActionsMenu.collapse(); // close the menu
FloatingActionsMenu.toggle(); // toggle the menu
FloatingActionsMenu.expand(); // open the mneu
In the Click listener
of the Menu Item
call .collapse()
Upvotes: 8