OnCancelListener is not called in DialogFragment

前端 未结 5 1389
盖世英雄少女心
盖世英雄少女心 2020-12-30 00:30

I have a simple AlertDialog that displays a list of some items and upon clicking one of them, the clicked item is passed back to the enclosing Activity

5条回答
  •  没有蜡笔的小新
    2020-12-30 01:27

    Cancel Listener or Dismiss listener in DialogFragment can achieve by onDismiss

                DialogFragment  newFragment = new DatePickerFragment();
                newFragment.show(getFragmentManager(), "datePicker");
                newFragment.onDismiss(new DialogInterface(){
    
                    @Override
                    public void cancel() {
                        // TODO Auto-generated method stub
    
                    }
    
                    @Override
                    public void dismiss() {
                        // TODO Auto-generated method stub
    
                    }
    
                });
    

提交回复
热议问题