I want to Dismiss the popup window by clicking outside of the popup window or by the back button, but when click on the back button my application exit\'s, instead of exitin
Maintain global reference for PopUpWindow and override onBackPressed()...
@Override
public void onBackPressed() {
if (popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
} else {
super.onBackPressed();
}
}
To dismiss by the same Button...
ivmainmenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
popupWindow = null;
} else {
// show pop up now
}
}
});