Android Open Source - CircularButton Main Activity






From Project

Back to project page CircularButton.

License

The source code is released under:

Apache License

If you think the Android project CircularButton 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 me.alexrs.circlebutton.demo;
//from   ww  w  .  ja va2  s  . c  o  m
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;

import me.alexrs.circularbutton.lib.CircularButton;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final CircularButton button = (CircularButton) findViewById(R.id.button);

        //Here is shown how you can change the color of the button and shadow.
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getBaseContext(), "CLICK!", Toast.LENGTH_SHORT).show();
                if (button.getButtonColor() == Color.WHITE) {
                    button.setButtonColor(Color.BLACK);
                    button.setShadowColor(Color.BLUE);
                } else {
                    button.setButtonColor(Color.WHITE);
                    button.setShadowColor(Color.GRAY);
                }
            }
        });
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}




Java Source Code List

me.alexrs.circlebutton.demo.MainActivity.java
me.alexrs.circularbutton.lib.CircularButton.java