【问题标题】:How to finish a fragment using kotlin如何使用 kotlin 完成片段
【发布时间】:2021-04-16 11:53:49
【问题描述】:

我尝试了activity?.finsish 之类的方法,但它关闭了整个应用程序。 这是我要完成片段的地方:

lifecycleScope.launch {
        delay(2000)
        findNavController().navigate(R.id.action_splashFragment_to_authenticationFragment)
       // Here I want to finish my Fragment
    }

还有其他解决方案吗?提前谢谢你

【问题讨论】:

    标签: android android-studio kotlin android-fragments


    【解决方案1】:
    val navOptions = NavOptions.Builder().setPopUpTo(R.id.splashFragment, true).build()
    findNavController().navigate(R.id.action_splashFragment_to_authenticationFragment, null, navOptions)
    

    【讨论】:

      猜你喜欢
      • 2017-04-24
      • 2012-10-19
      • 2017-11-22
      • 1970-01-01
      • 2019-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-30
      相关资源
      最近更新 更多