0

Hi I was implementing a floating button with this post: How do I create an Android material design UI widget?

and it works ! But I don`t know how to make this button clickable please help ?

Thanks :)

Community
  • 1
  • 1
AviNonimos
  • 13
  • 3

1 Answers1

1

You can hook up a onClickListener to the FloatingActionButton view. By the way, the answer you quoted here was derived from this blog post by John Hogan and here is the sample code hosted on Github in case you would like to see the entire code sample.

FloatingActionButton mFab = new FloatingActionButton.Builder(this)
            .withColor(getResources().getColor(R.color.accent_color))
            .withDrawable(getResources().getDrawable(R.drawable.fab_icon))
            .withSize(72)
            .withMargins(0, 0, 16, 16)
            .create();
mFab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // DO SOMETHING HERE
            }
        });
display name
  • 4,165
  • 2
  • 27
  • 52