popwindow on spinner item selection in android
===

i have a strange problem .i am using a spinner on selection of its items i am opening a popup window but problem  is that first time when any item is selected popup window opens but if that item is again selected popup does'nt open until any other item is selected before that item is selected again?? what should i do ?? plss help below is my code 

  

          @Override
    	public void onItemSelected(AdapterView<?> parent, View view, int position,
    			long id) {
    		// TODO Auto-generated method stub
    		switch (position) {
    		case 0:
    			
    			break;
            case 1:
            	pool_type_value=0;
            	option_selected=2;
            	calculation();
    			break;
    
            case 2:
    	        pool_type_value=1;
    	        option_selected=2;
    	        System.out.println("pop up case 2");
    	        openPopupWindow(pool_legend);
    	        
    	      
    	        break;
    
            case 3:
            	pool_type_value=2;
            	option_selected=2;
            	openPopupWindow(pool_legend);
            	
            	 
    	        break;
            case 4:
            	pool_type_value=0;
            	option_selected=1;
            	calculation();
    	        break;
    
    
    		default:
    			break;
    		}
    		
    	}
              
              private void openPopupWindow(Spinner spinner) {
    		// TODO Auto-generated method stub
    		int h = 0;
    		View popupView = null;
    		 Button btnDismiss = null;
    		LayoutInflater layoutInflater 
    	     = (LayoutInflater)getBaseContext()
    	      .getSystemService(LAYOUT_INFLATER_SERVICE); 
    		 System.out.println("pop up ");
    		if(width>240 && height>320)
    	 	  {
    			h=350;
    
    	 	  }
    		else if(width<=240 && height<=320){
    			h=200;
    		}
    		if(pool_type_value==1){
    		 popupView = layoutInflater.inflate(R.layout.popup_rectangle_extension, null);
    		 btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
    		 ed_width_single_extension=(EditText)popupView.findViewById(R.id.editText_singleextension_width);
    		 ed_length_single_extension=(EditText)popupView.findViewById(R.id.editText_singleextension_lenght);
    		    
    		 System.out.println("pop up 1");
    		 if(!hashmap.get("single_width").equals("0")){
    			 ed_width_single_extension.setText(""+hashmap.get("single_width"));
    		     }
    		    if(!hashmap.get("single_length").equals("0")){
    			 ed_length_single_extension.setText(""+hashmap.get("single_length"));
    		     }
    		 
    		}else if(pool_type_value==2){
    	     popupView = layoutInflater.inflate(R.layout.popup_rectangle_plus_extension, null);
    	     System.out.println("pop up 2");
    	     btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
    		}
    	             popupWindow = new PopupWindow(popupView, LayoutParams.FILL_PARENT,h);
    	             popupWindow.setTouchable(true);
    	             popupWindow.setFocusable(true);
    	            
    	             btnDismiss.setOnClickListener(new Button.OnClickListener(){
    
    					@Override
    					public void onClick(View v) {
    						// TODO Auto-generated method stub
    						hashmap.put("single_width", ed_width_single_extension.getText().toString());
    						hashmap.put("single_length", ed_length_single_extension.getText().toString());
    						calculation();
    						
    						popupWindow.dismiss();
    						// setDatabase();
    					}
    
    	   
    
    });
    
    	            
    	           
    	            popupWindow.showAtLocation( spinner, Gravity.CENTER, 0, 10);
    		
    		
    	}