安卓 : How to dismiss a DialogFragment on orientation change?

标签 android android-dialogfragment dismiss orientation-changes

我想在方向改变时关闭 DialogFragment。

问题是 OnConfigurationChanged() 永远不会被调用。

并调用:

this.dismiss();

OnDetach()方法中,返回空指针异常。我能做什么?

最佳答案

覆盖:

public void onPause() {
    super.onPause();

    this.dismiss();
}

而不是OnConfigurationChanged(),成功了。

关于安卓 : How to dismiss a DialogFragment on orientation change?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36118029/

相关文章:

ios - 如何从另一个 View 中关闭 Popover?

关于数据库的 Android 通知

android - 如果从 fragment 调用 DialogFragment 抛出 ClassCastException

android - java.lang.IllegalStateException : Can not perform this action after onSaveInstanceState with DialogFragment

android - 如何创建包含 fragment 的 Android 选项卡式对话框?

iphone - 关闭模态视图

ios - 使用选项卡栏 Controller 保留 View 时如何关闭 View

java - 登录后编辑/更新用户信息 [Android]

android - 读取文本文件并将数据填充到数组中。

java - 如何使需要相机支持的 ​​Android 应用程序在 Samsung Galaxy Mini 和类似设备上运行?