第一次弹出后,关闭按钮不起作用

时间:2017-01-04 12:13:27

标签: android

我已经构建了一个启动相机的应用程序,当点击图像时,它会显示在弹出窗口中.Pop窗口有两个按钮关闭并重新加载。当图像首次显示在弹出按钮中时,关闭按钮工作但我重新加载相机,然后单击图像关闭按钮不起作用 这是我用于弹出窗口的代码

    private void initiatePopupWindow() {
         LayoutInflater inflater = (LayoutInflater) MainActivity.this
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.layout, null);
    imageView = (ImageView) layout.findViewById(R.id.imageView1);
    android.os.Handler handler = new android.os.Handler();
    try {
        handler.postDelayed(new Runnable() {
            public void run() {
                pwindo = new PopupWindow(layout,500, 500, true);
                pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0);
            }
        }, 100);


        Button close = (Button) layout.findViewById(R.id.button3);
        Button reload = (Button) layout.findViewById(R.id.button2);


        reload.setOnClickListener(new OnClickListener() {

            public void onClick(View popupView) {
                openCamera();
            }
        });
        close.setOnClickListener(new OnClickListener() {

            public void onClick(View popupView) {
                pwindo.dismiss();
            }
        });


    } catch (Exception e) {
        e.printStackTrace();
    }
}
   public void openCamera() {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

    startActivityForResult(intent, CAMERA_REQUEST);


}

0 个答案:

没有答案