Android: Dismissing one popup window when the next is called?
<p>I have 3 Image buttons and on press they each have a Popup window that opens up. The issue is when i click on button 1, there is a popup, if I DONT dismiss that popup but click on Button 2 instead, the pop-up for Button 1 and Button 2 appear.
How do i dismiss any open Pop-up's when a new  button is pressed?</p>

<p>Here is my code</p>

<pre><code>final ImageButton rredButton=(ImageButton)findViewById(R.id.RredButton);
    rredButton.setOnClickListener(new View.OnClickListener() {

        public void onClick(View arg0) {
            LayoutInflater layoutInflater
            = (LayoutInflater)getBaseContext()      
            .getSystemService(LAYOUT_INFLATER_SERVICE);
            View popupView = layoutInflater.inflate(R.layout.popupright, null);
            final PopupWindow popupWindow = new PopupWindow(               
                    popupView,                
                    LayoutParams.WRAP_CONTENT,                       
                    LayoutParams.WRAP_CONTENT);     
            Button btnNxtScr = (Button)popupView.findViewById(R.id.nextscreen);             
            btnNxtScr.setOnClickListener(new Button.OnClickListener(){     
                @Override     
                public void onClick(View v) {      
                    Intent myintent1 = new Intent(colorActivity.this,colorBlueActivity.class);
                    startActivity(myintent1);
                }
            });
                    popupWindow.showAsDropDown(rredButton, 1, -1);
        }});
</code></pre>

<p>And here is the other button (with a similar popup method)</p>

<pre><code>final ImageButton ryellowButton=(ImageButton)findViewById(R.id.RyellowButton);
    ryellowButton.setOnClickListener(new View.OnClickListener() {
        @Override     
        public void onClick(View arg0) {          
            createWrongPop(arg0);      
            }});
</code></pre>
