ContextMenu
  public
  
  
  
  interface
  ContextMenu
  
  
      implements
      
        Menu
      
  
  
| android.view.ContextMenu | 
Extension of Menu for context menus providing functionality to modify
 the header of the context menu.
 
Context menus do not support item shortcuts and item icons.
 To show a context menu on long click, most clients will want to call
 Activity.registerForContextMenu and override
 Activity.onCreateContextMenu.
 
Developer Guides
For information about creating menus, read the Menus developer guide.
Summary
| Nested classes | |
|---|---|
| 
        
        
        
        
        interface | ContextMenu.ContextMenuInfoAdditional information regarding the creation of the context menu. | 
| Inherited constants | 
|---|
| Public methods | |
|---|---|
| 
        abstract
        
        
        
        
        void | 
      clearHeader()
      Clears the header of the context menu. | 
| 
        abstract
        
        
        
        
        ContextMenu | 
      setHeaderIcon(int iconRes)
      Sets the context menu header's icon to the icon given in iconRes resource id. | 
| 
        abstract
        
        
        
        
        ContextMenu | 
      setHeaderIcon(Drawable icon)
      Sets the context menu header's icon to the icon given in icon
  | 
| 
        abstract
        
        
        
        
        ContextMenu | 
      setHeaderTitle(int titleRes)
      Sets the context menu header's title to the title given in titleRes resource identifier. | 
| 
        abstract
        
        
        
        
        ContextMenu | 
      setHeaderTitle(CharSequence title)
      Sets the context menu header's title to the title given in title. | 
| 
        abstract
        
        
        
        
        ContextMenu | 
      setHeaderView(View view)
      Sets the header of the context menu to the  | 
| Inherited methods | |
|---|---|
Public methods
clearHeader
public abstract void clearHeader ()
Clears the header of the context menu.
setHeaderIcon
public abstract ContextMenu setHeaderIcon (int iconRes)
Sets the context menu header's icon to the icon given in iconRes resource id.
| Parameters | |
|---|---|
| iconRes | int: The resource identifier used for the icon. | 
| Returns | |
|---|---|
| ContextMenu | This ContextMenu so additional setters can be called. | 
setHeaderIcon
public abstract ContextMenu setHeaderIcon (Drawable icon)
Sets the context menu header's icon to the icon given in icon
 Drawable.
| Parameters | |
|---|---|
| icon | Drawable: TheDrawableused for the icon. | 
| Returns | |
|---|---|
| ContextMenu | This ContextMenu so additional setters can be called. | 
setHeaderTitle
public abstract ContextMenu setHeaderTitle (int titleRes)
Sets the context menu header's title to the title given in titleRes resource identifier.
| Parameters | |
|---|---|
| titleRes | int: The string resource identifier used for the title. | 
| Returns | |
|---|---|
| ContextMenu | This ContextMenu so additional setters can be called. | 
setHeaderTitle
public abstract ContextMenu setHeaderTitle (CharSequence title)
Sets the context menu header's title to the title given in title.
| Parameters | |
|---|---|
| title | CharSequence: The character sequence used for the title. | 
| Returns | |
|---|---|
| ContextMenu | This ContextMenu so additional setters can be called. | 
setHeaderView
public abstract ContextMenu setHeaderView (View view)
Sets the header of the context menu to the View given in
 view. This replaces the header title and icon (and those
 replace this).
| Parameters | |
|---|---|
| view | View: TheViewused for the header. | 
| Returns | |
|---|---|
| ContextMenu | This ContextMenu so additional setters can be called. | 
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.
