Search in sources :

Example 1 with OnStateChangedListener

use of com.wnafee.vector.MorphButton.OnStateChangedListener in project vector-compat by wnafee.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Example of adding MorphButton in java
    MorphButton mb = new MorphButton(this);
    LayoutParams p = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    mb.setLayoutParams(p);
    mb.setBackgroundTintList(getResources().getColorStateList(R.color.background_tint_color));
    mb.setForegroundTintList(getResources().getColorStateList(R.color.foreground_tint_color));
    mb.setStartDrawable(R.drawable.ic_pause_to_play);
    mb.setEndDrawable(R.drawable.ic_play_to_pause);
    mb.setOnStateChangedListener(new OnStateChangedListener() {

        @Override
        public void onStateChanged(MorphState changedTo, boolean isAnimating) {
            // Do something here
            Toast.makeText(MainActivity.this, "Changed to: " + changedTo, Toast.LENGTH_SHORT).show();
        }
    });
    LinearLayout ll = (LinearLayout) findViewById(R.id.base_view);
    ll.addView(mb);
}
Also used : OnStateChangedListener(com.wnafee.vector.MorphButton.OnStateChangedListener) LayoutParams(android.widget.LinearLayout.LayoutParams) MorphButton(com.wnafee.vector.MorphButton) MorphState(com.wnafee.vector.MorphButton.MorphState) LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)1 LayoutParams (android.widget.LinearLayout.LayoutParams)1 MorphButton (com.wnafee.vector.MorphButton)1 MorphState (com.wnafee.vector.MorphButton.MorphState)1 OnStateChangedListener (com.wnafee.vector.MorphButton.OnStateChangedListener)1