Stay organized with collections
Save and categorize content based on your preferences.
interface OnMenuItemClickListener
Interface definition for a callback to be invoked when a menu item is clicked.
Summary
Public methods |
abstract Boolean |
Called when a menu item has been invoked.
|
Public methods
abstract fun onMenuItemClick(item: MenuItem): Boolean
Called when a menu item has been invoked. This is the first code that is executed; if it returns true, no other callbacks will be executed.
Parameters |
item |
MenuItem: The menu item that was invoked. This value cannot be null . |
Return |
Boolean |
Return true to consume this click and prevent others from executing. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# MenuItem.OnMenuItemClickListener\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnMenuItemClickListener\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/view/MenuItem.OnMenuItemClickListener \"View this page in Java\") \n\n```\ninterface OnMenuItemClickListener\n```\n\n|----------------------------------------------------|\n| [android.view.MenuItem.OnMenuItemClickListener](#) |\n\nInterface definition for a callback to be invoked when a menu item is clicked.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [onMenuItemClick](#onMenuItemClick(android.view.MenuItem))`(`item:` `[MenuItem](/reference/kotlin/android/view/MenuItem)`)` Called when a menu item has been invoked. |\n\nPublic methods\n--------------\n\n### onMenuItemClick\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onMenuItemClick(item: MenuItem): Boolean\n```\n\nCalled when a menu item has been invoked. This is the first code that is executed; if it returns true, no other callbacks will be executed.\n\n| Parameters ||\n|--------|-------------------------------------------------------------------------------------------------------------------|\n| `item` | [MenuItem](/reference/kotlin/android/view/MenuItem): The menu item that was invoked. This value cannot be `null`. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | Return true to consume this click and prevent others from executing. |"]]