can't dismiss popUpWindow [duplicate]
问题 This question already has answers here : Android popup window dismissal (10 answers) Closed 5 years ago . i created my popUp window public void myPopUp() { LinearLayout myView = new LinearLayout(getApplicationContext()); pw = new PopupWindow(getApplicationContext()); pw.setContentView(myView); myView.setBackgroundColor(Color.WHITE); pw.setWidth(curWidth-100); pw.setHeight(curHeight-100); pw.showAtLocation(background, Gravity.CENTER, 0, 0); } and overrided backButton pressed for dissmis public