Android examples for User Interface:Button
button Click Effect
//package com.book2s; import android.graphics.Color; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; import android.widget.Button; public class Main { public static void buttonClickEffect(View button) { button.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Button btn = (Button) v; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { btn.setTextColor(Color.RED); btn.invalidate();/*from w w w . ja v a 2 s. c o m*/ break; } case MotionEvent.ACTION_UP: { btn.setTextColor(Color.WHITE); btn.invalidate(); break; } } return false; } }); } }