Fragment 中监听返回按键

2021-12-10  本文已影响0人  Obadiah
requireActivity()
    .onBackPressedDispatcher
    .addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
        override fun handleOnBackPressed() {
            if (isEnabled) {
                Log.d("test", "handleOnBackPressed: ")
            }
        }
    }
    )

上一篇下一篇

猜你喜欢

热点阅读