Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.graphics.PorterDuff;

import android.view.MotionEvent;
import android.view.View;
import android.widget.ImageView;

public class Main {
    public static void handleTouches(ImageView button) {
        button.setOnTouchListener(new View.OnTouchListener() {

            public boolean onTouch(View v, MotionEvent m) {
                if (m.getAction() == MotionEvent.ACTION_DOWN) {
                    darkenImage((ImageView) v);
                } else if (m.getAction() == MotionEvent.ACTION_UP) {
                    ((ImageView) v).setColorFilter(null);
                }
                return false;
            }
        });
    }

    public static void darkenImage(ImageView v) {
        v.setColorFilter(0x55000000, PorterDuff.Mode.SRC_ATOP);
    }
}