• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.annotation.DrawableRes;
20 import android.annotation.StringRes;
21 import android.app.Activity;
22 import android.graphics.drawable.Drawable;
23 import android.widget.AdapterView;
24 
25 /**
26  * Extension of {@link Menu} for context menus providing functionality to modify
27  * the header of the context menu.
28  * <p>
29  * Context menus do not support item shortcuts and item icons.
30  * <p>
31  * To show a context menu on long click, most clients will want to call
32  * {@link Activity#registerForContextMenu} and override
33  * {@link Activity#onCreateContextMenu}.
34  *
35  * <div class="special reference">
36  * <h3>Developer Guides</h3>
37  * <p>For information about creating menus, read the
38  * <a href="{@docRoot}guide/topics/ui/menus.html">Menus</a> developer guide.</p>
39  * </div>
40  */
41 public interface ContextMenu extends Menu {
42     /**
43      * Sets the context menu header's title to the title given in <var>titleRes</var>
44      * resource identifier.
45      *
46      * @param titleRes The string resource identifier used for the title.
47      * @return This ContextMenu so additional setters can be called.
48      */
setHeaderTitle(@tringRes int titleRes)49     public ContextMenu setHeaderTitle(@StringRes int titleRes);
50 
51     /**
52      * Sets the context menu header's title to the title given in <var>title</var>.
53      *
54      * @param title The character sequence used for the title.
55      * @return This ContextMenu so additional setters can be called.
56      */
setHeaderTitle(CharSequence title)57     public ContextMenu setHeaderTitle(CharSequence title);
58 
59     /**
60      * Sets the context menu header's icon to the icon given in <var>iconRes</var>
61      * resource id.
62      *
63      * @param iconRes The resource identifier used for the icon.
64      * @return This ContextMenu so additional setters can be called.
65      */
setHeaderIcon(@rawableRes int iconRes)66     public ContextMenu setHeaderIcon(@DrawableRes int iconRes);
67 
68     /**
69      * Sets the context menu header's icon to the icon given in <var>icon</var>
70      * {@link Drawable}.
71      *
72      * @param icon The {@link Drawable} used for the icon.
73      * @return This ContextMenu so additional setters can be called.
74      */
setHeaderIcon(Drawable icon)75     public ContextMenu setHeaderIcon(Drawable icon);
76 
77     /**
78      * Sets the header of the context menu to the {@link View} given in
79      * <var>view</var>. This replaces the header title and icon (and those
80      * replace this).
81      *
82      * @param view The {@link View} used for the header.
83      * @return This ContextMenu so additional setters can be called.
84      */
setHeaderView(View view)85     public ContextMenu setHeaderView(View view);
86 
87     /**
88      * Clears the header of the context menu.
89      */
clearHeader()90     public void clearHeader();
91 
92     /**
93      * Additional information regarding the creation of the context menu.  For example,
94      * {@link AdapterView}s use this to pass the exact item position within the adapter
95      * that initiated the context menu.
96      */
97     public interface ContextMenuInfo {
98     }
99 }
100