8
BottomSheetDialogFragment
의 최종 면제를 어떻게들을 수 있습니까? 대화 상자가에 (그것을 아래로 문질러하지 기각되는 경우,BottomSheetDialogFragment - 사용자 이벤트에 의해 해제 수신 대기
방법 1
이 단지 화재 : 나는 다음과 같은 노력
... 단지 최종 해고에 대한 사용자 변경 사항을 저장하려면 다시 눌러 또는 외부에 터치)
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
Dialog d = super.onCreateDialog(savedInstanceState);
d.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
BottomSheetDialog d = (BottomSheetDialog) dialog;
FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
BottomSheetBehavior behaviour = BottomSheetBehavior.from(bottomSheet);
behaviour.setState(BottomSheetBehavior.STATE_EXPANDED);
behaviour.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
if (newState == BottomSheetBehavior.STATE_HIDDEN)
{
// Bottom Sheet was dismissed by user! But this is only fired, if dialog is swiped down! Not if touch outside dismissed the dialog or the back button
Toast.makeText(MainApp.get(), "HIDDEN", Toast.LENGTH_SHORT).show();
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
}
});
return d;
}
방법 2
이
가 어떻게 나타내는 이벤트를 수신 할 수
@Override
public void onDismiss(DialogInterface dialog)
{
super.onDismiss(dialog);
// this works fine but fires one time too often for my use case, it fires on screen rotation as well, although this is a temporarily dismiss only
Toast.makeText(MainApp.get(), "DISMISSED", Toast.LENGTH_SHORT).show();
}
질문 ... 내가 최종 해고와 화면 회전 또는 활동 휴양에서 오는 일을 구별 할 수 없습니다 , 사용자가 대화 상자를 완료 했습니까?