Reputation: 377
I am trying to find out the Action Name that is being performed by the mouse. I tried
String act=String.valueof(event.getAction());
it returns me integer 3
.
Can anyone guide me with the list of integer associated with motionevent in android.
Upvotes: 0
Views: 1084
Reputation: 71
`
private static String getActionName(MotionEvent event) {
try {
for (Field f : MotionEvent.class.getFields()) {
if (f.getName().startsWith("ACTION_") &&
f.getInt(null) == event.getAction()) {
return f.getName();
}
}
}
catch (IllegalAccessException ignored) {}
return event.getAction()+"";
}
`
Upvotes: 0
Reputation: 95
It's not clear if anyone actually answered this question but regardless of the pedantry of whether it is a non-existant mouseevent or a MotionEvent
@Satyam asked how to get the name of the action not its value!! Instead of criticizing the questioner, or highlighting his knowledge gap, for not reading. it behoves the answerers to actually read the question. This should be used:
MotionEvent ev
me.actionToString (me.getAction());
It is very useful when logging an app's progress while debugging. I wish there was a similar method for the DragEvent
but I have to take a longer path...
Upvotes: 3
Reputation: 25873
There's no such thing as mouse event on Android. You probably meant MotionEvent
s. You have the description and explanation of each action in the official SDK documentation (which btw you should read before asking).
Upvotes: 0
Reputation: 30855
Checkout this link
http://developer.android.com/reference/android/view/MotionEvent.html#ACTION_CANCEL
MotionEvent
class have all listed event for finger touch
Upvotes: 0
Reputation: 26034
You can put code like,
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
//code here....
break;
case MotionEvent.ACTION_UP:
//code here....
break;
case MotionEvent.ACTION_MOVE:
//code here....
break;
case MotionEvent.ACTION_CANCEL:
//code here....
break;
}
Upvotes: 0