def OpenPopWindowButton_onClick(self, Ev):
//#create popup window
MyPopupWindow = Service.PopupWindowClass._New()
//#set onDismiss event listener
def MyPopupWindow_onDismiss(self, Ev):
Service.ToastClass._New().makeText("PopupWindow is dismiss",0).show();
return;
MyPopupWindow.onDismiss = MyPopupWindow_onDismiss;
//#create root layout for popup window
PopupLayout = Service.LinearLayoutClass._New();
PopupLayout.setBackgroundColor(0xFF0000FF) #--blue
//#create a button
MyButton = Service.ButtonClass._New(PopupLayout);
def MyButton_onClick(self, Ev) :
//#when is clicked, we show information and close the popup window
Service.ToastClass._New().makeText("Button is click",0).show();
MyPopupWindow.dismiss();
return;
MyButton.onClick = MyButton_onClick;
MyButton.setText("CloseWindow");
MyButton.setLinearLayoutParams(Service.WRAP_CONTENT,Service.WRAP_CONTENT);
//#assign layout to popup window.
MyPopupWindow.setContentView(PopupLayout);
MyPopupWindow.setWidth(200);
MyPopupWindow.setHeight(200);
MyPopupWindow.setFocusable(True);
MyPopupWindow.showAtLocation(self,17,0,0);
//#prevent garbage collected by python.
MyPopupWindow._LockGC();
return;