dismiss the popup window by back button

前端 未结 6 1280
感情败类
感情败类 2020-12-17 17:38

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

6条回答
  •  -上瘾入骨i
    2020-12-17 18:35

    Try this..

    Use PopupWindow popupWindow as Global variable

    use popup.setOutsideTouchable(true);

    @Override
    public void onBackPressed() {
        if (popupWindow != null) {
            if (popupWindow.isShowing()) {
                popupWindow.dismiss();
            }
        } else {
            finish();
        }
    }
    

提交回复
热议问题