Android Open Source - android-floating-action-button Main Activity






From Project

Back to project page android-floating-action-button.

License

The source code is released under:

Apache License

If you think the Android project android-floating-action-button listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package in.sahidave.floatingactiobutton.sample;
//from   w  w  w. j  a  v  a  2 s  .com
import in.sahildave.floatingactionbutton.FloatingActionButton;
import in.sahildave.floatingactionbutton.FloatingActionsMenu;
import in.sahildave.floatingactionbutton.sample.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class MainActivity extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    findViewById(R.id.pink_icon).setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
        Toast.makeText(MainActivity.this, "Clicked pink Floating Action Button", Toast.LENGTH_SHORT).show();
      }
    });

    FloatingActionButton button = (FloatingActionButton) findViewById(R.id.setter);
    button.setSize(FloatingActionButton.SIZE_MINI);
    button.setColorNormalResId(R.color.pink);
    button.setColorPressedResId(R.color.pink_pressed);
    button.setIcon(R.drawable.ic_fab_star);

    FloatingActionButton actionC = new FloatingActionButton(getBaseContext());
    ((FloatingActionsMenu) findViewById(R.id.multiple_actions)).addButton(actionC);

    final FloatingActionButton actionA = (FloatingActionButton) findViewById(R.id.action_a);
    actionA.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
        actionA.setTitle("Action A clicked");
      }
    });
  }
}




Java Source Code List

in.sahidave.floatingactiobutton.sample.MainActivity.java
in.sahildave.floatingactionbutton.FloatingActionButton.java
in.sahildave.floatingactionbutton.FloatingActionsMenu.java
in.sahildave.floatingactionbutton.PlusFloatingActionButton.java