📜  在fragemnt 2021 kotlin代码示例中按下处理onback

📅  最后修改于: 2022-03-11 14:53:34.085000             🧑  作者: Mango

代码示例1
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    // Listen to Back button clicks
    val callback = requireActivity().onBackPressedDispatcher.addCallback(this) {
        // Handle the back button event
    }
}