Popup layer

Hello guys,
Here is the codes for popup layer. The problem is that it is not being removed.
I have created a popup layer and I call below method.
[java]

public void PopupRaise(){

	 Element popupElement = nifty.createPopup("PopupRaise");
	 if(flag==0)
	 {
	   
	 nifty.showPopup(nifty.getCurrentScreen(), popupElement.getId(), null);
	 flag=1;
	 }
	 else if(flag==1)
	 {
		// Element popupElement = nifty.createPopup("PopupRaise"); 
			nifty.closePopup(popupElement.getId());
			flag=0;
	 }
}

[/java]

First,when I press a button that calls above method, the popup window appears. The popup window contains a textfield and a button to exit popup layer. But When I press that exit button, it is not being removed.
Please help on this.
Thanks.

You are creating a new element with a different id each time your method is called.

1 Like