1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.view; 18 19 import android.app.Activity; 20 import android.graphics.drawable.Drawable; 21 import android.widget.AdapterView; 22 23 /** 24 * Extension of {@link Menu} for context menus providing functionality to modify 25 * the header of the context menu. 26 * <p> 27 * Context menus do not support item shortcuts and item icons. 28 * <p> 29 * To show a context menu on long click, most clients will want to call 30 * {@link Activity#registerForContextMenu} and override 31 * {@link Activity#onCreateContextMenu}. 32 * 33 * <div class="special reference"> 34 * <h3>Developer Guides</h3> 35 * <p>For information about creating menus, read the 36 * <a href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide.</p> 37 * </div> 38 */ 39 public interface ContextMenu extends Menu { 40 /** 41 * Sets the context menu header's title to the title given in <var>titleRes</var> 42 * resource identifier. 43 * 44 * @param titleRes The string resource identifier used for the title. 45 * @return This ContextMenu so additional setters can be called. 46 */ setHeaderTitle(int titleRes)47 public ContextMenu setHeaderTitle(int titleRes); 48 49 /** 50 * Sets the context menu header's title to the title given in <var>title</var>. 51 * 52 * @param title The character sequence used for the title. 53 * @return This ContextMenu so additional setters can be called. 54 */ setHeaderTitle(CharSequence title)55 public ContextMenu setHeaderTitle(CharSequence title); 56 57 /** 58 * Sets the context menu header's icon to the icon given in <var>iconRes</var> 59 * resource id. 60 * 61 * @param iconRes The resource identifier used for the icon. 62 * @return This ContextMenu so additional setters can be called. 63 */ setHeaderIcon(int iconRes)64 public ContextMenu setHeaderIcon(int iconRes); 65 66 /** 67 * Sets the context menu header's icon to the icon given in <var>icon</var> 68 * {@link Drawable}. 69 * 70 * @param icon The {@link Drawable} used for the icon. 71 * @return This ContextMenu so additional setters can be called. 72 */ setHeaderIcon(Drawable icon)73 public ContextMenu setHeaderIcon(Drawable icon); 74 75 /** 76 * Sets the header of the context menu to the {@link View} given in 77 * <var>view</var>. This replaces the header title and icon (and those 78 * replace this). 79 * 80 * @param view The {@link View} used for the header. 81 * @return This ContextMenu so additional setters can be called. 82 */ setHeaderView(View view)83 public ContextMenu setHeaderView(View view); 84 85 /** 86 * Clears the header of the context menu. 87 */ clearHeader()88 public void clearHeader(); 89 90 /** 91 * Additional information regarding the creation of the context menu. For example, 92 * {@link AdapterView}s use this to pass the exact item position within the adapter 93 * that initiated the context menu. 94 */ 95 public interface ContextMenuInfo { 96 } 97 } 98