I Want to close popupWindow after pressing backbutton. The popUp Window is in View Pager which is in Activity. The back button doesnt react for any touch.(when the popUp is close works fine) I set the BackgroundDrawable and OutsideTouchable and still nothing.
public class popUp extends PopupWindow implements ViewPager.OnPageChangeListener,
View.OnClickListener{
public popUp{
setContentView(view);
setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
setOutsideTouchable(true);
setFocusable(true);
showAtLocation(view, Gravity.CENTER, 0,0);
setBackgroundDrawable(new ColorDrawable());
}}
Activity
@Override
public void onBackPressed() {
if(ViewPagerAdapter!=null){
if (ViewPagerAdapter.popUp!= null && ViewPagerAdapter.popUp.isShowing())
ViewPagerAdapter.popUp.dismiss();
else
super.onBackPressed();
}
}