Convert motion Event type To String - Android android.view

Android examples for android.view:MotionEvent

Description

Convert motion Event type To String

Demo Code

import android.content.Context;
import android.graphics.Rect;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewGroup;

public class Main{

    public static String motionEventToString(MotionEvent ev) {
        switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            return "ACTION_DOWN";
        case MotionEvent.ACTION_UP:
            return "ACTION_UP";
        case MotionEvent.ACTION_MOVE:
            return "ACTION_MOVE";
        case MotionEvent.ACTION_CANCEL:
            return "ACTION_CANCEL";
        default:/*from   w w  w.j  ava 2s  .  c  om*/
            return "ACTION_UNDEFINE " + ev.getActionMasked();
        }
    }

}

Related Tutorials