首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打乱BottomSheetDialogFragment

打乱BottomSheetDialogFragment
EN

Stack Overflow用户
提问于 2020-09-07 03:49:53
回答 1查看 53关注 0票数 0

我有两个BottomSheetDialogFragment : BottomSheetDialogFragment1和BottomSheetDialogFragment2,我想从BottomSheetDialogFragment1转到BottomSheetDialogFragment2,这是如下代码示例

代码语言:javascript
复制
    val bottomSheetDialogFragment2 = BottomSheetDialogFragment2()
        bottomSheetDialogFragment2.show(childFragmentManager, bottomSheetDialogFragment1.tag)

但是当我像下面的代码一样重定向到bottomSheetDialogFragment2之后,我会忽略BottomSheetDialogFragment2

代码语言:javascript
复制
        val bottomSheetDialogFragment2 = BottomSheetDialogFragment2()
        bottomSheetDialogFragment2.show(childFragmentManager, bottomSheetDialogFragment1.tag)

dismiss()

结果是: BottomSheetDialogFragment1和BottomSheetDialogFragment2都使用了BottomSheet (),而我只喜欢忽略一个and。

EN

回答 1

Stack Overflow用户

发布于 2020-09-07 07:46:45

尝试使用activity中的片段管理器:

代码语言:javascript
复制
  val bottomSheetDialogFragment2 = BottomSheetDialogFragment2()
  bottomSheetDialogFragment2.show(parentFragmentManager, bottomSheetDialogFragment1.tag)

此外,您还可以使用showNow方法来防止在对话框之间转换时屏幕上的闪烁:

代码语言:javascript
复制
  val bottomSheetDialogFragment2 = BottomSheetDialogFragment2()
  bottomSheetDialogFragment2.showNow(parentFragmentManager,bottomSheetDialogFragment1.tag)

请注意,如果您在将此方法附加到activity之前调用此方法,则parentFragmentManager方法可能会抛出异常,以下是文档:

https://developer.android.com/reference/androidx/fragment/app/Fragment#getParentFragmentManager()

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63768292

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档