View.CancelPendingInputEvents Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Cancel any deferred high-level input events that were previously posted to the event queue.
[Android.Runtime.Register("cancelPendingInputEvents", "()V", "")]
public void CancelPendingInputEvents ();
[<Android.Runtime.Register("cancelPendingInputEvents", "()V", "")>]
member this.CancelPendingInputEvents : unit -> unit
- Attributes
Remarks
Cancel any deferred high-level input events that were previously posted to the event queue.
Many views post high-level events such as click handlers to the event queue to run deferred in order to preserve a desired user experience - clearing visible pressed states before executing, etc. This method will abort any events of this nature that are currently in flight.
Custom views that generate their own high-level deferred input events should override #onCancelPendingInputEvents()
and remove those pending events from the queue.
This will also cancel pending input events for any child views.
Note that this may not be sufficient as a debouncing strategy for clicks in all cases. This will not impact newer events posted after this call that may occur as a result of lower-level input events still waiting in the queue. If you are trying to prevent double-submitted events for the duration of some sort of asynchronous transaction you should also take other steps to protect against unexpected double inputs e.g. calling #setEnabled(boolean) setEnabled(false)
and re-enabling the view when the transaction completes, tracking already submitted transaction IDs, etc.
Java documentation for android.view.View.cancelPendingInputEvents()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.