Android examples for User Interface:View Click
add View Click Wrong Effect
//package com.java2s; import android.graphics.PorterDuff; import android.view.MotionEvent; import android.view.View; public class Main { public static void addClickWrongEffect(View view) { view.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { v.getBackground().setColorFilter(0x55FF0000, PorterDuff.Mode.SRC_ATOP); v.invalidate();//from w w w . j a v a 2s .c o m return true; } case MotionEvent.ACTION_UP: { v.getBackground().clearColorFilter(); v.invalidate(); v.performClick(); return false; } } return false; } }); } }