Android ExpandableListAdapter中子级的上下文菜单

Android ExpandableListAdapter中子级的上下文菜单,android,contextmenu,parent-child,expandablelistview,children,Android,Contextmenu,Parent Child,Expandablelistview,Children,如果用户长时间单击ExpandableListAdater的项目(组或组子项),我试图创建一个ContextMenu,但是ContextMenu仅显示长时间单击组项,而不显示组子项: 一旦创建: @Override protected void onCreate(Bundle savedInstanceState) { //... setListAdapter(mAdapter); registerForContextMenu(getExpandableListView(

如果用户长时间单击
ExpandableListAdater
的项目(组或组子项),我试图创建一个
ContextMenu
,但是
ContextMenu
仅显示长时间单击组项,而不显示组子项:

一旦创建:

@Override
protected void onCreate(Bundle savedInstanceState) {
    //...
    setListAdapter(mAdapter);
    registerForContextMenu(getExpandableListView());
onCreateContextMenu:

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    Log.i("", "Click");
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);

    // Show context menu for groups
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        menu.setHeaderTitle("Group");
        menu.add(0, 0, 1, "Delete");

        // Show context menu for children
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        menu.setHeaderTitle("Child");
        menu.add(0, 0, 1, "Delete");
    }
}
onContextItemSelected:

@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item
            .getMenuInfo();

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        // do something with parent

    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        // do someting with child
    }

    return super.onContextItemSelected(item);
}
我想我错过了一些东西,因为如果我长时间点击一个孩子,“点击”不会被记录。我认为如果我长时间单击一个孩子,就不会调用
onCreateContextMenu
。如何为
ExpandableListAdapter
组子级显示
ContextMenu

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    // Check your child items here
    return true;
}
自动实现为
返回false