Most visited

Recently visited

Added in API level 1

Window.Callback

public static interface Window.Callback

android.view.Window.Callback
Known Indirect Subclasses


从窗口返回到调用者的API。 这允许客户拦截关键调度,面板和菜单等。

Summary

Public methods

abstract boolean dispatchGenericMotionEvent(MotionEvent event)

被调用来处理通用运动事件。

abstract boolean dispatchKeyEvent(KeyEvent event)

被调用来处理关键事件。

abstract boolean dispatchKeyShortcutEvent(KeyEvent event)

被调用来处理键快捷键事件。

abstract boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)

打电话来处理 AccessibilityEvent的人口。

abstract boolean dispatchTouchEvent(MotionEvent event)

被调用来处理触摸屏事件。

abstract boolean dispatchTrackballEvent(MotionEvent event)

被称为处理轨迹球事件。

abstract void onActionModeFinished(ActionMode mode)

当动作模式完成时调用。

abstract void onActionModeStarted(ActionMode mode)

当动作模式已启动时调用。

abstract void onAttachedToWindow()

当窗口已连接到窗口管理器时调用。

abstract void onContentChanged()

只要屏幕的内容视图发生变化(由于致电 Window.setContentViewWindow.addContentView ),就会调用此钩子。

abstract boolean onCreatePanelMenu(int featureId, Menu menu)

初始化面板'featureId'的菜单内容。

abstract View onCreatePanelView(int featureId)

实例化视图以显示在“featureId”的面板中。

abstract void onDetachedFromWindow()

当窗口已连接到窗口管理器时调用。

abstract boolean onMenuItemSelected(int featureId, MenuItem item)

当用户选择了面板的菜单项时调用。

abstract boolean onMenuOpened(int featureId, Menu menu)

用户打开面板菜单时调用。

abstract void onPanelClosed(int featureId, Menu menu)

当面板关闭时调用。

abstract boolean onPreparePanel(int featureId, View view, Menu menu)

准备要显示的面板。

default void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId)

在当前窗口请求键盘快捷键时调用。

abstract boolean onSearchRequested()

当用户指示开始搜索的愿望时调用。

abstract boolean onSearchRequested(SearchEvent searchEvent)

当用户指示开始搜索的愿望时调用。

abstract void onWindowAttributesChanged(WindowManager.LayoutParams attrs)

这在每当当前窗口属性改变时被调用。

abstract void onWindowFocusChanged(boolean hasFocus)

这个钩子在窗口焦点改变时被调用。

abstract ActionMode onWindowStartingActionMode(ActionMode.Callback callback)

当此窗口的动作模式正在启动时调用。

abstract ActionMode onWindowStartingActionMode(ActionMode.Callback callback, int type)

当此窗口的动作模式正在启动时调用。

Public methods

dispatchGenericMotionEvent

Added in API level 12
boolean dispatchGenericMotionEvent (MotionEvent event)

被调用来处理通用运动事件。 至少您的实现必须调用superDispatchGenericMotionEvent(MotionEvent)来执行标准处理。

Parameters
event MotionEvent: The generic motion event.
Returns
boolean boolean Return true if this event was consumed.

dispatchKeyEvent

Added in API level 1
boolean dispatchKeyEvent (KeyEvent event)

被调用来处理关键事件。 至少你的实现必须调用superDispatchKeyEvent(KeyEvent)来执行标准的密钥处理。

Parameters
event KeyEvent: The key event.
Returns
boolean boolean Return true if this event was consumed.

dispatchKeyShortcutEvent

Added in API level 11
boolean dispatchKeyShortcutEvent (KeyEvent event)

被调用来处理键快捷键事件。 至少您的实现必须调用superDispatchKeyShortcutEvent(KeyEvent)来执行标准快捷键处理。

Parameters
event KeyEvent: The key shortcut event.
Returns
boolean True if this event was consumed.

dispatchPopulateAccessibilityEvent

Added in API level 4
boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

打电话来处理 AccessibilityEvent的人口。

Parameters
event AccessibilityEvent: The event.
Returns
boolean boolean Return true if event population was completed.

dispatchTouchEvent

Added in API level 1
boolean dispatchTouchEvent (MotionEvent event)

被调用来处理触摸屏事件。 至少您的实现必须调用superDispatchTouchEvent(MotionEvent)来执行标准触摸屏处理。

Parameters
event MotionEvent: The touch screen event.
Returns
boolean boolean Return true if this event was consumed.

dispatchTrackballEvent

Added in API level 1
boolean dispatchTrackballEvent (MotionEvent event)

被称为处理轨迹球事件。 至少你的实现必须调用superDispatchTrackballEvent(MotionEvent)来执行标准的轨迹球处理。

Parameters
event MotionEvent: The trackball event.
Returns
boolean boolean Return true if this event was consumed.

onActionModeFinished

Added in API level 11
void onActionModeFinished (ActionMode mode)

当动作模式完成时调用。 适当的模式回调方法已经被调用。

Parameters
mode ActionMode: The mode that was just finished.

onActionModeStarted

Added in API level 11
void onActionModeStarted (ActionMode mode)

当动作模式已启动时调用。 适当的模式回调方法已经被调用。

Parameters
mode ActionMode: The new mode that has just been started.

onAttachedToWindow

Added in API level 5
void onAttachedToWindow ()

当窗口已连接到窗口管理器时调用。 有关更多信息,请参阅View.onAttachedToWindow()

onContentChanged

Added in API level 1
void onContentChanged ()

只要屏幕的内容视图发生变化(由于致电 Window.setContentViewWindow.addContentView ),就会调用此钩子。

onCreatePanelMenu

Added in API level 1
boolean onCreatePanelMenu (int featureId, 
                Menu menu)

初始化面板'featureId'的菜单内容。 如果onCreatePanelView()返回null,这会被调用,为您提供一个标准菜单,您可以在其中放置项目。 它仅在面板显示时才被调用一次。

您可以安全地按住 菜单 (以及从中创建的任何项目),根据需要对其进行修改,直到下次为此功能调用onCreatePanelMenu()。

Parameters
featureId int: The panel being created.
menu Menu: The menu inside the panel.
Returns
boolean boolean You must return true for the panel to be displayed; if you return false it will not be shown.

onCreatePanelView

Added in API level 1
View onCreatePanelView (int featureId)

实例化视图以显示在“featureId”的面板中。 您可以返回null,在这种情况下,将为您创建默认内容(通常是菜单)。

Parameters
featureId int: Which panel is being created.
Returns
View view The top-level view to place in the panel.

也可以看看:

onDetachedFromWindow

Added in API level 5
void onDetachedFromWindow ()

当窗口已连接到窗口管理器时调用。 有关更多信息,请参阅View.onDetachedFromWindow()

onMenuItemSelected

Added in API level 1
boolean onMenuItemSelected (int featureId, 
                MenuItem item)

当用户选择了面板的菜单项时调用。

Parameters
featureId int: The panel that the menu is in.
item MenuItem: The menu item that was selected.
Returns
boolean boolean Return true to finish processing of selection, or false to perform the normal menu handling (calling its Runnable or sending a Message to its target Handler).

onMenuOpened

Added in API level 1
boolean onMenuOpened (int featureId, 
                Menu menu)

用户打开面板菜单时调用。 当菜单从一种类型更改为另一种时(例如,从图标菜单变为扩展菜单),也可能会调用此功能。

Parameters
featureId int: The panel that the menu is in.
menu Menu: The menu that is opened.
Returns
boolean Return true to allow the menu to open, or false to prevent the menu from opening.

onPanelClosed

Added in API level 1
void onPanelClosed (int featureId, 
                Menu menu)

当面板关闭时调用。 如果正在打开另一个逻辑后续面板(并且该面板正在关闭以为后面的面板腾出空间),则不会调用此方法。

Parameters
featureId int: The panel that is being displayed.
menu Menu: If onCreatePanelView() returned null, this is the Menu being displayed in the panel.

onPreparePanel

Added in API level 1
boolean onPreparePanel (int featureId, 
                View view, 
                Menu menu)

准备要显示的面板。 在每次显示面板窗口之前调用它。

Parameters
featureId int: The panel that is being displayed.
view View: The View that was returned by onCreatePanelView().
menu Menu: If onCreatePanelView() returned null, this is the Menu being displayed in the panel.
Returns
boolean boolean You must return true for the panel to be displayed; if you return false it will not be shown.

也可以看看:

onProvideKeyboardShortcuts

Added in API level 24
void onProvideKeyboardShortcuts (List<KeyboardShortcutGroup> data, 
                Menu menu, 
                int deviceId)

在当前窗口请求键盘快捷键时调用。

Parameters
data List: The data list to populate with shortcuts.
menu Menu: The current menu, which may be null.
deviceId int: The id for the connected device the shortcuts should be provided for.

onSearchRequested

Added in API level 1
boolean onSearchRequested ()

当用户指示开始搜索的愿望时调用。

Returns
boolean true if search launched, false if activity refuses (blocks)

也可以看看:

onSearchRequested

Added in API level 23
boolean onSearchRequested (SearchEvent searchEvent)

当用户指示开始搜索的愿望时调用。

Parameters
searchEvent SearchEvent: A SearchEvent describing the signal to start a search.
Returns
boolean true if search launched, false if activity refuses (blocks)

onWindowAttributesChanged

Added in API level 1
void onWindowAttributesChanged (WindowManager.LayoutParams attrs)

这在每当当前窗口属性改变时被调用。

Parameters
attrs WindowManager.LayoutParams

onWindowFocusChanged

Added in API level 1
void onWindowFocusChanged (boolean hasFocus)

这个钩子在窗口焦点改变时被调用。 有关更多信息,请参阅View.onWindowFocusChangedNotLocked(boolean)

Parameters
hasFocus boolean: Whether the window now has focus.

onWindowStartingActionMode

Added in API level 11
ActionMode onWindowStartingActionMode (ActionMode.Callback callback)

当此窗口的动作模式正在启动时调用。 给回调提供了一个机会,以自己独特而美丽的方式处理动作模式。 如果此方法返回null,则系统可以选择一种呈现模式的方式或根本不选择启动模式。 这相当于onWindowStartingActionMode(android.view.ActionMode.Callback, int) ,类型为TYPE_PRIMARY

Parameters
callback ActionMode.Callback: Callback to control the lifecycle of this action mode
Returns
ActionMode The ActionMode that was started, or null if the system should present it

onWindowStartingActionMode

Added in API level 23
ActionMode onWindowStartingActionMode (ActionMode.Callback callback, 
                int type)

当此窗口的动作模式正在启动时调用。 给回调提供了一个机会,以自己独特而美丽的方式处理动作模式。 如果此方法返回null,则系统可以选择一种呈现模式的方式或根本不选择启动模式。

Parameters
callback ActionMode.Callback: Callback to control the lifecycle of this action mode
type int: One of TYPE_PRIMARY or TYPE_FLOATING.
Returns
ActionMode The ActionMode that was started, or null if the system should present it

Hooray!