View.OnGenericMotionEvent(MotionEvent) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
實作這個方法來處理泛型動作事件。
[Android.Runtime.Register("onGenericMotionEvent", "(Landroid/view/MotionEvent;)Z", "GetOnGenericMotionEvent_Landroid_view_MotionEvent_Handler")]
public virtual bool OnGenericMotionEvent (Android.Views.MotionEvent? e);
[<Android.Runtime.Register("onGenericMotionEvent", "(Landroid/view/MotionEvent;)Z", "GetOnGenericMotionEvent_Landroid_view_MotionEvent_Handler")>]
abstract member OnGenericMotionEvent : Android.Views.MotionEvent -> bool
override this.OnGenericMotionEvent : Android.Views.MotionEvent -> bool
參數
正在處理的泛型動作事件。
傳回
如果已處理事件,則為 True,否則為 false。
- 屬性
備註
實作這個方法來處理泛型動作事件。
一般動作事件描述搖桿移動、滑鼠或手寫筆裝置的暫留事件、觸控板觸控、滾輪移動和其他未由 #onTouchEvent(MotionEvent)
或 #onTrackballEvent(MotionEvent)
處理的動作事件。 動作事件的 會 MotionEvent#getSource() source
指定收到的輸入類別。 這個方法的實作必須先檢查來源中的位,再處理事件。 下列程式碼範例示範如何完成此作業。
具有來源類別 InputDevice#SOURCE_CLASS_POINTER
的泛型動作事件會傳遞至指標底下的檢視。 所有其他泛型動作事件都會傳遞至焦點檢視。
public boolean onGenericMotionEvent(MotionEvent event) {
if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
// process the joystick movement...
return true;
}
}
if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
case MotionEvent.ACTION_HOVER_MOVE:
// process the hover movement...
return true;
case MotionEvent.ACTION_SCROLL:
// process the scroll wheel movement...
return true;
}
}
return super.onGenericMotionEvent(event);
}
的 android.view.View.onGenericMotionEvent(android.view.MotionEvent)
JAVA 檔。
此頁面的部分是根據所建立和共用的工作進行修改,並根據 2.5 屬性授權中所述的詞彙來使用。