Bat*_*1k3 3 android bottom-sheet
我使用以下代码显示 BottomSheetDialogFragment:
BottomSheetDialogFragment bottomSheetDialogFragment = new MediaAddFragment();
bottomSheetDialogFragment.show(getActivity().getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
getActivity().getSupportFragmentManager().executePendingTransactions();
bottomSheetDialogFragment.getDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
onResume();
MainActivity.updateMediaButtons();
}
});
Run Code Online (Sandbox Code Playgroud)
要关闭它,我从 Fragment 中调用 Dismiss() 。这样,它就会被关闭,但如果应用程序恢复,它会再次显示,这不是我的意图。
如果有人能帮助我解决这个问题,我会很高兴。我已经扫描了有关如何正确使用这些 BottomSheetDialogFragments 的各种教程,但我找不到我的错误。
顺便说一句,我在 onResume 中没有任何代码来测试它。
(代表OP发布)。
我发现我的错误,我正在覆盖调用片段中 BottomSheetDialogFragment 的 onDismissListener 。现在它按预期工作了。
bottomSheetDialogFragment2.getDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// Adding the following line fixed the problem for me
bottomSheetDialogFragment2.onDismiss(dialog);
// some Code....
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3025 次 |
| 最近记录: |