Callback
interface Callback
android.view.Window.Callback |
API from a Window back to its caller. This allows the client to intercept key dispatching, panels and menus, etc.
Summary
Public methods | |
---|---|
abstract Boolean |
dispatchGenericMotionEvent(event: MotionEvent!) Called to process generic motion events. |
abstract Boolean |
dispatchKeyEvent(event: KeyEvent!) Called to process key events. |
abstract Boolean |
dispatchKeyShortcutEvent(event: KeyEvent!) Called to process a key shortcut event. |
abstract Boolean |
Called to process population of |
abstract Boolean |
dispatchTouchEvent(event: MotionEvent!) Called to process touch screen events. |
abstract Boolean |
dispatchTrackballEvent(event: MotionEvent!) Called to process trackball events. |
abstract Unit |
onActionModeFinished(mode: ActionMode!) Called when an action mode has been finished. |
abstract Unit |
onActionModeStarted(mode: ActionMode!) Called when an action mode has been started. |
abstract Unit |
Called when the window has been attached to the window manager. |
abstract Unit |
This hook is called whenever the content view of the screen changes (due to a call to |
abstract Boolean |
onCreatePanelMenu(featureId: Int, : Menu) Initialize the contents of the menu for panel 'featureId'. |
abstract View? |
onCreatePanelView(featureId: Int) Instantiate the view to display in the panel for 'featureId'. |
abstract Unit |
Called when the window has been detached from the window manager. |
abstract Boolean |
onMenuItemSelected(featureId: Int, item: MenuItem) Called when a panel's menu item has been selected by the user. |
abstract Boolean |
onMenuOpened(featureId: Int, : Menu) Called when a panel's menu is opened by the user. |
abstract Unit |
onPanelClosed(featureId: Int, : Menu) Called when a panel is being closed. |
open Unit |
onPointerCaptureChanged(hasCapture: Boolean) Called when pointer capture is enabled or disabled for the current window. |
abstract Boolean |
onPreparePanel(featureId: Int, view: View?, : Menu) Prepare a panel to be displayed. |
open Unit |
onProvideKeyboardShortcuts(data: MutableList<KeyboardShortcutGroup!>!, : Menu?, deviceId: Int) Called when Keyboard Shortcuts are requested for the current window. |
abstract Boolean |
Called when the user signals the desire to start a search. |
abstract Boolean |
onSearchRequested(searchEvent: SearchEvent!) Called when the user signals the desire to start a search. |
abstract Unit |
This is called whenever the current window attributes change. |
abstract Unit |
onWindowFocusChanged(hasFocus: Boolean) This hook is called whenever the window focus changes. |
abstract ActionMode? |
onWindowStartingActionMode(callback: ActionMode.Callback!) Called when an action mode is being started for this window. |
abstract ActionMode? |
onWindowStartingActionMode(callback: ActionMode.Callback!, type: Int) Called when an action mode is being started for this window. |
Public methods
dispatchGenericMotionEvent
abstract fun dispatchGenericMotionEvent(event: MotionEvent!): Boolean
Called to process generic motion events. At the very least your implementation must call android.view.Window#superDispatchGenericMotionEvent
to do the standard processing.
Parameters | |
---|---|
event |
MotionEvent!: The generic motion event. |
Return | |
---|---|
Boolean |
boolean Return true if this event was consumed. |
dispatchKeyEvent
abstract fun dispatchKeyEvent(event: KeyEvent!): Boolean
Called to process key events. At the very least your implementation must call android.view.Window#superDispatchKeyEvent
to do the standard key processing.
Parameters | |
---|---|
event |
KeyEvent!: The key event. |
Return | |
---|---|
Boolean |
boolean Return true if this event was consumed. |
dispatchKeyShortcutEvent
abstract fun dispatchKeyShortcutEvent(event: KeyEvent!): Boolean
Called to process a key shortcut event. At the very least your implementation must call android.view.Window#superDispatchKeyShortcutEvent
to do the standard key shortcut processing.
Parameters | |
---|---|
event |
KeyEvent!: The key shortcut event. |
Return | |
---|---|
Boolean |
True if this event was consumed. |
dispatchPopulateAccessibilityEvent
abstract fun dispatchPopulateAccessibilityEvent(event: AccessibilityEvent!): Boolean
Called to process population of AccessibilityEvent
s.
Parameters | |
---|---|
event |
AccessibilityEvent!: The event. |
Return | |
---|---|
Boolean |
boolean Return true if event population was completed. |
dispatchTouchEvent
abstract fun dispatchTouchEvent(event: MotionEvent!): Boolean
Called to process touch screen events. At the very least your implementation must call android.view.Window#superDispatchTouchEvent
to do the standard touch screen processing.
Parameters | |
---|---|
event |
MotionEvent!: The touch screen event. |
Return | |
---|---|
Boolean |
boolean Return true if this event was consumed. |
dispatchTrackballEvent
abstract fun dispatchTrackballEvent(event: MotionEvent!): Boolean
Called to process trackball events. At the very least your implementation must call android.view.Window#superDispatchTrackballEvent
to do the standard trackball processing.
Parameters | |
---|---|
event |
MotionEvent!: The trackball event. |
Return | |
---|---|
Boolean |
boolean Return true if this event was consumed. |
onActionModeFinished
abstract fun onActionModeFinished(mode: ActionMode!): Unit
Called when an action mode has been finished. The appropriate mode callback method will have already been invoked.
Parameters | |
---|---|
mode |
ActionMode!: The mode that was just finished. |
onActionModeStarted
abstract fun onActionModeStarted(mode: ActionMode!): Unit
Called when an action mode has been started. The appropriate mode callback method will have already been invoked.
Parameters | |
---|---|
mode |
ActionMode!: The new mode that has just been started. |
onAttachedToWindow
abstract fun onAttachedToWindow(): Unit
Called when the window has been attached to the window manager. See View.onAttachedToWindow()
for more information.
onContentChanged
abstract fun onContentChanged(): Unit
This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView
or Window.addContentView
).
onCreatePanelMenu
abstract fun onCreatePanelMenu(
featureId: Int,
: Menu
): Boolean
Initialize the contents of the menu for panel 'featureId'. This is called if onCreatePanelView() returns null, giving you a standard menu in which you can place your items. It is only called once for the panel, the first time it is shown.
You can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreatePanelMenu() is called for this feature.
Parameters | |
---|---|
featureId |
Int: The panel being created. |
menu |
Menu: The menu inside the panel. This value cannot be null . |
Return | |
---|---|
Boolean |
boolean You must return true for the panel to be displayed; if you return false it will not be shown. |
onCreatePanelView
abstract fun onCreatePanelView(featureId: Int): View?
Instantiate the view to display in the panel for 'featureId'. You can return null, in which case the default content (typically a menu) will be created for you.
Parameters | |
---|---|
featureId |
Int: Which panel is being created. |
Return | |
---|---|
View? |
view The top-level view to place in the panel. |
See Also
onDetachedFromWindow
abstract fun onDetachedFromWindow(): Unit
Called when the window has been detached from the window manager. See View.onDetachedFromWindow()
for more information.
onMenuItemSelected
abstract fun onMenuItemSelected(
featureId: Int,
item: MenuItem
): Boolean
Called when a panel's menu item has been selected by the user.
Parameters | |
---|---|
featureId |
Int: The panel that the menu is in. |
item |
MenuItem: The menu item that was selected. This value cannot be null . |
Return | |
---|---|
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
abstract fun onMenuOpened(
featureId: Int,
: Menu
): Boolean
Called when a panel's menu is opened by the user. This may also be called when the menu is changing from one type to another (for example, from the icon menu to the expanded menu).
Parameters | |
---|---|
featureId |
Int: The panel that the menu is in. |
menu |
Menu: The menu that is opened. This value cannot be null . |
Return | |
---|---|
Boolean |
Return true to allow the menu to open, or false to prevent the menu from opening. |
onPanelClosed
abstract fun onPanelClosed(
featureId: Int,
: Menu
): Unit
Called when a panel is being closed. If another logical subsequent panel is being opened (and this panel is being closed to make room for the subsequent panel), this method will NOT be called.
Parameters | |
---|---|
featureId |
Int: The panel that is being displayed. |
menu |
Menu: If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |
onPointerCaptureChanged
open fun onPointerCaptureChanged(hasCapture: Boolean): Unit
Called when pointer capture is enabled or disabled for the current window.
Parameters | |
---|---|
hasCapture |
Boolean: True if the window has pointer capture. |
onPreparePanel
abstract fun onPreparePanel(
featureId: Int,
view: View?,
: Menu
): Boolean
Prepare a panel to be displayed. This is called right before the panel window is shown, every time it is shown.
Parameters | |
---|---|
featureId |
Int: The panel that is being displayed. |
view |
View?: The View that was returned by onCreatePanelView(). This value may be null . |
menu |
Menu: If onCreatePanelView() returned null, this is the Menu being displayed in the panel. |
Return | |
---|---|
Boolean |
boolean You must return true for the panel to be displayed; if you return false it will not be shown. |
See Also
onProvideKeyboardShortcuts
open fun onProvideKeyboardShortcuts(
data: MutableList<KeyboardShortcutGroup!>!,
: Menu?,
deviceId: Int
): Unit
Called when Keyboard Shortcuts are requested for the current window.
Parameters | |
---|---|
data |
MutableList<KeyboardShortcutGroup!>!: 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
abstract fun onSearchRequested(): Boolean
Called when the user signals the desire to start a search.
Return | |
---|---|
Boolean |
true if search launched, false if activity refuses (blocks) |
onSearchRequested
abstract fun onSearchRequested(searchEvent: SearchEvent!): Boolean
Called when the user signals the desire to start a search.
Parameters | |
---|---|
searchEvent |
SearchEvent!: A SearchEvent describing the signal to start a search. |
Return | |
---|---|
Boolean |
true if search launched, false if activity refuses (blocks) |
onWindowAttributesChanged
abstract fun onWindowAttributesChanged(attrs: WindowManager.LayoutParams!): Unit
This is called whenever the current window attributes change.
onWindowFocusChanged
abstract fun onWindowFocusChanged(hasFocus: Boolean): Unit
This hook is called whenever the window focus changes. See View.onWindowFocusChangedNotLocked(boolean)
for more information.
Parameters | |
---|---|
hasFocus |
Boolean: Whether the window now has focus. |
onWindowStartingActionMode
abstract fun onWindowStartingActionMode(callback: ActionMode.Callback!): ActionMode?
Called when an action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all. This is equivalent to onWindowStartingActionMode(android.view.ActionMode.Callback,int)
with type ActionMode.TYPE_PRIMARY
.
Parameters | |
---|---|
callback |
ActionMode.Callback!: Callback to control the lifecycle of this action mode |
Return | |
---|---|
ActionMode? |
The ActionMode that was started, or null if the system should present it |
onWindowStartingActionMode
abstract fun onWindowStartingActionMode(
callback: ActionMode.Callback!,
type: Int
): ActionMode?
Called when an action mode is being started for this window. Gives the callback an opportunity to handle the action mode in its own unique and beautiful way. If this method returns null the system can choose a way to present the mode or choose not to start the mode at all.
Parameters | |
---|---|
callback |
ActionMode.Callback!: Callback to control the lifecycle of this action mode |
type |
Int: One of ActionMode.TYPE_PRIMARY or ActionMode.TYPE_FLOATING . |
Return | |
---|---|
ActionMode? |
The ActionMode that was started, or null if the system should present it |