小编Aru*_*run的帖子

关闭Android中的弹出窗口

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

谢谢

android popup android-widget

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

android-widget ×1

popup ×1