如何重新加载menuinfo Android?

时间:2014-08-17 02:47:39

标签: android contextmenu expandablelistview

我在expandaple列表视图中使用上下文菜单,当在其上添加新子项时,我需要告诉系统哪个子项将获取上下文菜单

我尝试使用onPrepareOptionsMenu,但它没有给我menuInfo。有什么想法吗?

这是我的代码:

public void onCreateContextMenu(ContextMenu menu, View v,
                                    ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);

        final EntryDAO dao = EntryDAO.getInstance(this);

        ExpandableListView.ExpandableListContextMenuInfo info =
                (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

        int type =
                ExpandableListView.getPackedPositionType(info.packedPosition);

        final int groupPosition =
                ExpandableListView.getPackedPositionGroup(info.packedPosition);

        final int childPosition =
                ExpandableListView.getPackedPositionChild(info.packedPosition);

        // Only create a context menu for child items
        if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD && childPosition < listDataChild.get(listDataHeader.get(groupPosition)).size() - 1) {
        }
    }

1 个答案:

答案 0 :(得分:0)

没关系,问题出在我的BaseAdapter实现中。设置点击Android正在回收的子项,以便长时间点击无效。