{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
public class MotionEventBuilder
A helper builder for creating MotionEvent's.
Default values for unspecified attributes are 0 unless otherwise noted.
Public constructors |
|
|---|---|
Public methods |
|
|---|---|
MotionEvent |
build()Returns a MotionEvent with the provided data or reasonable defaults. |
static MotionEventBuilder |
Start building a new MotionEvent. |
MotionEventBuilder |
setAction(int action)Sets the action. |
MotionEventBuilder |
setActionIndex(int pointerIndex)Sets the pointer index associated with the action. |
MotionEventBuilder |
setButtonState(int buttonState)Sets the button state. |
MotionEventBuilder |
setDeviceId(int deviceId)Sets the device id. |
MotionEventBuilder |
setDownTime(long downTime)Sets the down time. |
MotionEventBuilder |
setEdgeFlags(int edgeFlags)Sets the edge flags. |
MotionEventBuilder |
setEventTime(long eventTime)Sets the event time. |
MotionEventBuilder |
setFlags(int flags)Sets the flags. |
MotionEventBuilder |
setMetaState(int metastate)Sets the metaState. |
MotionEventBuilder |
setPointer(float x, float y)Simple mechanism to add a pointer to the MotionEvent. |
MotionEventBuilder |
setPointer(An expanded variant of |
MotionEventBuilder |
setSource(int source)Sets the source. |
MotionEventBuilder |
setXPrecision(float xPrecision)Sets the x precision. |
MotionEventBuilder |
setYPrecision(float yPrecision)Sets the y precision. |
public MotionEvent build()
Returns a MotionEvent with the provided data or reasonable defaults.
public static MotionEventBuilder newBuilder()
Start building a new MotionEvent.
| Returns | |
|---|---|
MotionEventBuilder |
a new MotionEventBuilder. |
public MotionEventBuilder setAction(int action)
Sets the action. Default is MotionEvent.ACTION_DOWN.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setActionIndex(int pointerIndex)
Sets the pointer index associated with the action.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setButtonState(int buttonState)
Sets the button state.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setDeviceId(int deviceId)
Sets the device id.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setDownTime(long downTime)
Sets the down time.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setEdgeFlags(int edgeFlags)
Sets the edge flags.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setEventTime(long eventTime)
Sets the event time. Default is SystemClock.uptimeMillis().
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setMetaState(int metastate)
Sets the metaState.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setPointer(float x, float y)
Simple mechanism to add a pointer to the MotionEvent.
Can be called multiple times to add multiple pointers to the event.
public MotionEventBuilder setPointer(
PointerProperties pointerProperties,
PointerCoords pointerCoords
)
An expanded variant of setPointer that supports specifying all pointer properties and coords data.
public MotionEventBuilder setXPrecision(float xPrecision)
Sets the x precision.
| See also | |
|---|---|
MotionEvent |
|
public MotionEventBuilder setYPrecision(float yPrecision)
Sets the y precision.
| See also | |
|---|---|
MotionEvent |
|