【问题标题】:How to hide BottomSheetDialogFragment after navigating to another fragment导航到另一个片段后如何隐藏 BottomSheetDialogFragment
【发布时间】:2021-04-05 15:13:44
【问题描述】:

我有在它的 XML 中包含 ImgaeView(s) 的片段,我正在从这些图像导航到另一个片段,但问题是底页保持打开状态,当我导航到另一个片段时如何使其折叠?

这是底片的图片

在这里我导航到另一个片段,但底部表格仍然出现在屏幕上

这是片段内部的代码

class MoreFragment : BottomSheetDialogFragment() {


override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
): View? {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_more, container, false)


}


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)



    home_button.setOnClickListener{
        val homeFragment = HomeFragment()
        activity?.supportFragmentManager?.beginTransaction()
            ?.replace(R.id.nav_host_fragment, homeFragment, "findThisFragment")
            ?.addToBackStack(null)
            ?.commit()
        
    }

所以我的问题是:

导航到另一个片段后如何使其折叠?

【问题讨论】:

    标签: android kotlin navigation fragment bottom-sheet


    【解决方案1】:

    在导航到另一个片段调用dismiss()函数之前在Onclick侦听器中

    【讨论】:

    • 太棒了.. 只需将答案标记为已验证,以便其他人受益
    猜你喜欢
    • 1970-01-01
    • 2015-01-10
    • 2013-12-19
    • 2013-05-12
    • 2020-09-03
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    • 2020-10-17
    相关资源
    最近更新 更多