private void initPopupWindow(View parent) {
View v = getActivity().getLayoutInflater().inflate(R.layout.popupwindow_show_dialog, null);
PopupWindow popup = new PopupWindow(v, LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT, true);
popup.setFocusable(true);
// 该属性设置为true则你在点击屏幕的空白位置也会退出
popup.setTouchable(true);
popup.setOutsideTouchable(true);popup.showAtLocation(parent, Gravity.CENTER, 0, 0);
}
这样写是可以的,必须传一个父级的view进去,也就是你的pop在哪个view上弹出。