我有以下功能,它通过单击菜单按钮调用弹出窗口。它有一个确定按钮来关闭弹出窗口。但该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();
}
});
谢谢