public
final
class
MotionEventCompat
extends Object
java.lang.Object | |
↳ | android.support.v4.view.MotionEventCompat |
Helper for accessing features in MotionEvent
introduced
after API level 4 in a backwards compatible fashion.
Public methods | |
---|---|
static
int
|
findPointerIndex(MotionEvent event, int pointerId)
Call |
static
int
|
getActionIndex(MotionEvent event)
Call |
static
int
|
getActionMasked(MotionEvent event)
Call |
static
float
|
getAxisValue(MotionEvent event, int axis)
Get axis value for the first pointer index (may be an arbitrary pointer identifier). |
static
float
|
getAxisValue(MotionEvent event, int axis, int pointerIndex)
Returns the value of the requested axis for the given pointer index
(use |
static
int
|
getButtonState(MotionEvent event)
|
static
int
|
getPointerCount(MotionEvent event)
The number of pointers of data contained in this event. |
static
int
|
getPointerId(MotionEvent event, int pointerIndex)
Call |
static
int
|
getSource(MotionEvent event)
Gets the source of the event. |
static
float
|
getX(MotionEvent event, int pointerIndex)
Call |
static
float
|
getY(MotionEvent event, int pointerIndex)
Call |
static
boolean
|
isFromSource(MotionEvent event, int source)
Determines whether the event is from the given source. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int ACTION_HOVER_ENTER
Synonym for ACTION_HOVER_ENTER
.
Constant Value: 9 (0x00000009)
int ACTION_HOVER_EXIT
Synonym for ACTION_HOVER_EXIT
.
Constant Value: 10 (0x0000000a)
int ACTION_HOVER_MOVE
Synonym for ACTION_HOVER_MOVE
.
Constant Value: 7 (0x00000007)
int ACTION_POINTER_DOWN
Synonym for ACTION_POINTER_DOWN
.
Constant Value: 5 (0x00000005)
int ACTION_POINTER_INDEX_MASK
Synonym for ACTION_POINTER_INDEX_MASK
.
Constant Value: 65280 (0x0000ff00)
int ACTION_POINTER_INDEX_SHIFT
Synonym for ACTION_POINTER_INDEX_SHIFT
.
Constant Value: 8 (0x00000008)
int ACTION_POINTER_UP
Synonym for ACTION_POINTER_UP
.
Constant Value: 6 (0x00000006)
int findPointerIndex (MotionEvent event, int pointerId)
Call findPointerIndex(int)
.
If running on a pre-ECLAIR
device,
does nothing and returns -1.
Parameters | |
---|---|
event |
MotionEvent
|
pointerId |
int
|
Returns | |
---|---|
int |
int getActionIndex (MotionEvent event)
Call getAction()
, returning only the pointer index
portion
Parameters | |
---|---|
event |
MotionEvent
|
Returns | |
---|---|
int |
int getActionMasked (MotionEvent event)
Call getAction()
, returning only the ACTION_MASK
portion.
Parameters | |
---|---|
event |
MotionEvent
|
Returns | |
---|---|
int |
float getAxisValue (MotionEvent event, int axis)
Get axis value for the first pointer index (may be an arbitrary pointer identifier).
Parameters | |
---|---|
event |
MotionEvent
|
axis |
int :
The axis identifier for the axis value to retrieve. |
Returns | |
---|---|
float |
float getAxisValue (MotionEvent event, int axis, int pointerIndex)
Returns the value of the requested axis for the given pointer index
(use getPointerId(MotionEvent, int)
to find the pointer identifier for this index).
Parameters | |
---|---|
event |
MotionEvent
|
axis |
int :
The axis identifier for the axis value to retrieve. |
pointerIndex |
int :
Raw index of pointer to retrieve. Value may be from 0
(the first pointer that is down) to getPointerCount(MotionEvent) -1. |
Returns | |
---|---|
float |
The value of the axis, or 0 if the axis is not available. |
int getPointerCount (MotionEvent event)
The number of pointers of data contained in this event. Always >= 1.
Parameters | |
---|---|
event |
MotionEvent
|
Returns | |
---|---|
int |
int getPointerId (MotionEvent event, int pointerIndex)
Call getPointerId(int)
.
If running on a pre-ECLAIR
device,
IndexOutOfBoundsException
is thrown.
Parameters | |
---|---|
event |
MotionEvent
|
pointerIndex |
int
|
Returns | |
---|---|
int |
int getSource (MotionEvent event)
Gets the source of the event.
Parameters | |
---|---|
event |
MotionEvent
|
Returns | |
---|---|
int |
The event source or SOURCE_UNKNOWN if unknown.
|
float getX (MotionEvent event, int pointerIndex)
Call getX(int)
.
If running on a pre-ECLAIR
device,
IndexOutOfBoundsException
is thrown.
Parameters | |
---|---|
event |
MotionEvent
|
pointerIndex |
int
|
Returns | |
---|---|
float |
float getY (MotionEvent event, int pointerIndex)
Call getY(int)
.
If running on a pre-ECLAIR
device,
IndexOutOfBoundsException
is thrown.
Parameters | |
---|---|
event |
MotionEvent
|
pointerIndex |
int
|
Returns | |
---|---|
float |
boolean isFromSource (MotionEvent event, int source)
Determines whether the event is from the given source.
Parameters | |
---|---|
event |
MotionEvent
|
source |
int :
The input source to check against. |
Returns | |
---|---|
boolean |
Whether the event is from the given source. |