Skip to content

Instantly share code, notes, and snippets.

@Xiryl
Created August 29, 2021 09:59
Embed
What would you like to do?
fragmentcallback-2
override fun onCreate(savedInstanceState: Bundle?) {
showFragment()
}
// callback listener
private val fragmentBackPressedListener = object : OnFragmentCallback {
override fun onFragmentBackPressed() {
foo()
}
}
// launch fragment
private val showFragment() {
val frag = YourCustomFragment(
backPressedListener = backPressedListener
)
frag.show(parentFragmentManager, "PopupFragment")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment