01
/**Extra menu information provided to
02
03
*the android.view.View.OnCreateContextMenuListener
04
05
*.onCreateContextMenu(ContextMenu, View, ContextMenuInfo) callback when
06
07
*a context menu is brought up for this AdapterView.
08
09
**/
10
11
public static class AdapterContextMenuInfo implements ContextMenu.ContextMenuInfo {
12
13
public AdapterContextMenuInfo(View targetView, int position, long id) {
14
this.targetView = targetView;
15
this.position = position;
16
this.id = id;
17
}
18
19
/**
20
* The child view for which the context menu is being displayed. This
21
* will be one of the children of this AdapterView.
22
*/
23
public View targetView;
24
25
/**
26
* The position in the adapter for which the context menu is being
27
* displayed.
28
*/
29
public int position;
30
31
/**
32
* The row id of the item for which the context menu is being displayed.
33
*/
34
public long id;
35
}
36
用法:
37
AdapterView.AdapterContextMenuInfo info;
38
try {
39
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
40
} catch (ClassCastException e) {
41
Log.e(TAG, "bad menuInfo", e);
42
return false;
43
}