PopupWindow中的ListView,ContextMenu不会弹出长按

时间:2010-08-18 13:31:40

标签: android listview contextmenu popupwindow

fileListView = new FileListController(this);
fileListView.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        pWindow.dismiss();
    }
});

pWindow = new PopupWindow(fileListView);
pWindow.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
pWindow.setTouchable(true);
button_show.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        if (pWindow.isShowing()) {
            pWindow.dismiss();
            return;
        }
        pWindow.showAsDropDown(v);
        pWindow.setFocusable(true);
        pWindow.update();
    }
});
fileListView.listView.setLongClickable(true);
registerForContextMenu(fileListView.listView);

1 个答案:

答案 0 :(得分:0)

您必须明确设置宽度和高度。

pWindow.setHeight(100);
pWindow.setWidth(100);