AlertDialog setOnDismissListener not working

前端 未结 6 1374
孤独总比滥情好
孤独总比滥情好 2021-02-19 11:44

My activity opens a dialog. When it closes I need the function ReloadTable() to be executed. So I am trying to use setOnDismissListener but its not get

6条回答
  •  孤街浪徒
    2021-02-19 12:44

    Use following code

    final AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
                    final View dailogView = LayoutInflater.from(MyActivity.this).inflate(R.layout.dialog_layout, null);
                    builder.setView(dailogView);
                    final AlertDialog dialog=builder.create();
                    dialog.show();
    

    DismissListener

     dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialogInterface) {
                       // your code after dissmiss dialog     
                        }
                    });
    

提交回复
热议问题