2011-02-09 71 views
0

我必须显示一个popup窗口。如果我在ImageView的单击事件中显示它,那么我称它为隐藏它。但是,当我在ImageView的Touch事件中显示它时,请关闭事件调用,但弹出窗口不会隐藏。这个错误的原因是什么?我如何解决它?PopUpWindow解雇问题

我用来显示弹出窗口的代码是

DisplayMetrics dm = new DisplayMetrics(); 
    getWindowManager().getDefaultDisplay().getMetrics(dm); 
    int width = dm.widthPixels; //320  
    CabotMessageHandler.printConsole("width of screen"+width); 

    //show Popup 
    LayoutInflater inflater = (LayoutInflater) 
     this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    popupView=inflater.inflate(R.layout.gallerytoppopup, null, false); 
    pw = new PopupWindow(
     popupView, 
     width, 
     30, 
     true); 
    // The code below assumes that the root container has an id called 'main' 
    pw.setAnimationStyle(R.anim.popupanimation); 
    pw.showAtLocation(this.findViewById(R.id.webview), Gravity.TOP, 0, 30); 

回答

0

最后我发现问题。触摸事件调用两次,并创建两个弹出窗口。这就是在被解雇时不隐藏Popup的原因(一个弹出窗口隐藏,另一个仍然存在)。