I have created a android application where I have created a popup screen. But when I am pressing the back button, popup is not getting closed.
I have tried with onB
//here "popUp" is ref of PopupWindow
popUp.setBackgroundDrawable(new BitmapDrawable());// it is most important peace of code
// For Key Listeners
View v = popUp.getContentView();
//Here assigning the key Listners
v.setOnKeyListener(this);
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK) popUp.dismiss();
return false;
}//Implements the KeyListener
//and be careful we should implement "OnKeyListener"`
I hope it is useful (I'm the new user)