我有以下功能,从菜单按钮单击调用弹出窗口.它有一个关闭弹出窗口的确定按钮.但是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();
}
});
Run Code Online (Sandbox Code Playgroud)
谢谢