# View.OnCreateContextMenuListener

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# OnCreateContextMenuListener

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/view/View.OnCreateContextMenuListener "View this page in Java")  

```
interface OnCreateContextMenuListener
```

|------------------------------------------------------------------------------------------------------------------------------------------------|
| [android.view.View.OnCreateContextMenuListener](https://developer.android.com/reference/kotlin/android/view/View.OnCreateContextMenuListener#) |

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Direct Subclasses [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#),[Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#),[ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#),[Fragment](https://developer.android.com/reference/kotlin/android/app/Fragment.html#) |-------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#)                             | An activity is a single, focused thing that the user can do.                                                                                                                        | | [Dialog](https://developer.android.com/reference/kotlin/android/app/Dialog.html#)                                 | Base class for Dialogs.                                                                                                                                                             | | [ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#) | An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item. | | [Fragment](https://developer.android.com/reference/kotlin/android/app/Fragment.html#)                             | A Fragment is a piece of an application's user interface or behavior that can be placed in an[Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#). | |

|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known Indirect Subclasses [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#),[ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#),[AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#),[AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#),[CharacterPickerDialog](https://developer.android.com/reference/kotlin/android/text/method/CharacterPickerDialog.html#),[DatePickerDialog](https://developer.android.com/reference/kotlin/android/app/DatePickerDialog.html#),[DialogFragment](https://developer.android.com/reference/kotlin/android/app/DialogFragment.html#),[ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#),[LauncherActivity](https://developer.android.com/reference/kotlin/android/app/LauncherActivity.html#),[ListActivity](https://developer.android.com/reference/kotlin/android/app/ListActivity.html#),[ListFragment](https://developer.android.com/reference/kotlin/android/app/ListFragment.html#),[NativeActivity](https://developer.android.com/reference/kotlin/android/app/NativeActivity.html#), and 7 others. |------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [AccountAuthenticatorActivity](https://developer.android.com/reference/kotlin/android/accounts/AccountAuthenticatorActivity.html#) | Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator.                                                                                                                                                                                                                                                                                                             | | [ActivityGroup](https://developer.android.com/reference/kotlin/android/app/ActivityGroup.html#)                                    | A screen that contains and runs multiple embedded activities.                                                                                                                                                                                                                                                                                                                                                       | | [AlertDialog](https://developer.android.com/reference/kotlin/android/app/AlertDialog.html#)                                        | A subclass of Dialog that can display one, two or three buttons.                                                                                                                                                                                                                                                                                                                                                    | | [AliasActivity](https://developer.android.com/reference/kotlin/android/app/AliasActivity.html#)                                    | Stub activity that launches another activity (and then finishes itself) based on information in its component's manifest meta-data.                                                                                                                                                                                                                                                                                 | | [CharacterPickerDialog](https://developer.android.com/reference/kotlin/android/text/method/CharacterPickerDialog.html#)            | Dialog for choosing accented characters related to a base character.                                                                                                                                                                                                                                                                                                                                                | | [DatePickerDialog](https://developer.android.com/reference/kotlin/android/app/DatePickerDialog.html#)                              | A simple dialog containing an[android.widget.DatePicker](https://developer.android.com/reference/kotlin/android/widget/DatePicker.html#).                                                                                                                                                                                                                                                                           | | [DialogFragment](https://developer.android.com/reference/kotlin/android/app/DialogFragment.html#)                                  | A fragment that displays a dialog window, floating on top of its activity's window.                                                                                                                                                                                                                                                                                                                                 | | [ExpandableListActivity](https://developer.android.com/reference/kotlin/android/app/ExpandableListActivity.html#)                  | An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item.                                                                                                                                                                                                                                 | | [LauncherActivity](https://developer.android.com/reference/kotlin/android/app/LauncherActivity.html#)                              | Displays a list of all activities which can be performed for a given intent.                                                                                                                                                                                                                                                                                                                                        | | [ListActivity](https://developer.android.com/reference/kotlin/android/app/ListActivity.html#)                                      | An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.                                                                                                                                                                                                                                                         | | [ListFragment](https://developer.android.com/reference/kotlin/android/app/ListFragment.html#)                                      | A fragment that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.                                                                                                                                                                                                                                                          | | [NativeActivity](https://developer.android.com/reference/kotlin/android/app/NativeActivity.html#)                                  | Convenience for implementing an activity that will be implemented purely in native code.                                                                                                                                                                                                                                                                                                                            | | [PreferenceActivity](https://developer.android.com/reference/kotlin/android/preference/PreferenceActivity.html#)                   | This is the base class for an activity to show a hierarchy of preferences to the user.                                                                                                                                                                                                                                                                                                                              | | [PreferenceFragment](https://developer.android.com/reference/kotlin/android/preference/PreferenceFragment.html#)                   | Shows a hierarchy of[Preference](https://developer.android.com/reference/kotlin/android/preference/Preference.html#)objects as lists.                                                                                                                                                                                                                                                                               | | [Presentation](https://developer.android.com/reference/kotlin/android/app/Presentation.html#)                                      | Base class for presentations.                                                                                                                                                                                                                                                                                                                                                                                       | | [ProgressDialog](https://developer.android.com/reference/kotlin/android/app/ProgressDialog.html#)                                  | A dialog showing a progress indicator and an optional text message or view.                                                                                                                                                                                                                                                                                                                                         | | [TabActivity](https://developer.android.com/reference/kotlin/android/app/TabActivity.html#)                                        | For apps developing against[android.os.Build.VERSION_CODES#HONEYCOMB](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#HONEYCOMB:kotlin.Int)or later, tabs are typically presented in the UI using the new[ActionBar.newTab()](https://developer.android.com/reference/kotlin/android/app/ActionBar.html#newTab())and related APIs for placing tabs within their action bar area. | | [TimePickerDialog](https://developer.android.com/reference/kotlin/android/app/TimePickerDialog.html#)                              | A dialog that prompts the user for the time of day using a[TimePicker](https://developer.android.com/reference/kotlin/android/widget/TimePicker.html#).                                                                                                                                                                                                                                                             | | [WebViewFragment](https://developer.android.com/reference/kotlin/android/webkit/WebViewFragment.html#)                             | A fragment that displays a WebView.                                                                                                                                                                                                                                                                                                                                                                                 | |

Interface definition for a callback to be invoked when the context menu for this view is being built.

## Summary

|                                                                                                                                                                                                                                                                                                                                                  Public methods                                                                                                                                                                                                                                                                                                                                                   ||
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onCreateContextMenu](https://developer.android.com/reference/kotlin/android/view/View.OnCreateContextMenuListener#onCreateContextMenu(android.view.ContextMenu,%20android.view.View,%20android.view.ContextMenu.ContextMenuInfo))`(`menu:` `[ContextMenu](https://developer.android.com/reference/kotlin/android/view/ContextMenu)!`, `v:` `[View](https://developer.android.com/reference/kotlin/android/view/View)!`, `menuInfo:` `[ContextMenu.ContextMenuInfo](https://developer.android.com/reference/kotlin/android/view/ContextMenu.ContextMenuInfo)!`)` Called when the context menu for this view is being built. |

## Public methods

### onCreateContextMenu

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun onCreateContextMenu(
    menu: ContextMenu!, 
    v: View!, 
    menuInfo: ContextMenu.ContextMenuInfo!
): Unit
```

Called when the context menu for this view is being built. It is not safe to hold onto the menu after this method returns.

|                                                                                                                                Parameters                                                                                                                                ||
|------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `menu`     | [ContextMenu](https://developer.android.com/reference/kotlin/android/view/ContextMenu)!:The context menu that is being built                                                                                                                                 |
| `v`        | [View](https://developer.android.com/reference/kotlin/android/view/View)!:The view for which the context menu is being built                                                                                                                                 |
| `menuInfo` | [ContextMenu.ContextMenuInfo](https://developer.android.com/reference/kotlin/android/view/ContextMenu.ContextMenuInfo)!:Extra information about the item for which the context menu should be shown. This information will vary depending on the class of v. |