Android: Why DialogFragment return nullpointer on orientation change

前端 未结 2 1719
陌清茗
陌清茗 2021-01-27 07:59

I have a problem with correct dialog fragment dismissing after that orientation was changed. I guess that\'s due to old context because after that activity was recreated there w

2条回答
  •  清歌不尽
    2021-01-27 08:28

    Fix is found. Maybe, it's already was written in the one of the fixes of google community which helps to avoid simple dismissing on orientation change and I miss it.

    I don't know already. In my case, I have set setRetainInstance(true) in onCreate method of DialogFragment.

    Implemented onDismiss method with simple fix and my last minor problem was that I didn't remove super.onDestroyView() in onDismiss method. Now it's working like a charm.

提交回复
热议问题