我有一个函数,它从菜单按钮点击调用弹出窗口。它有一个“确定”按钮来关闭弹出窗口。但是在按下按钮时onclick
函数没有被启动。另外,我需要在按下返回按钮时关闭弹出窗口。
LayoutInflater inflater = (LayoutInflater) MainActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.about_popup, null, false),400,440, true);
pw.showAtLocation(lv, Gravity.CENTER, 0, 0);
View popupView=inflater.inflate(R.layout.about_popup, null, false);
Button close = (Button) popupView.findViewById(R.id.okbutton);
close.setOnClickListener(new OnClickListener() {
public void onClick(View popupView) {
pw.dismiss();
}
});
谢谢