pippo10
pippo10

Reputation: 513

Close floating action button Android

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

Answers (2)

Leroy Ortiz
Leroy Ortiz

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

JafarKhQ
JafarKhQ

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

Related Questions