I am moving from Fragment A to Fragment B. When I ...
# android
m
I am moving from Fragment A to Fragment B. When I press back button, Fragment A is recreated. I wish to avoid this. How do I do it? I am using Navigation Component e.g.
findNavController().navigate(R.id.showDetailScreen)
g
Fragment probably not recreated, but view does But anyway, it's not related to Kotlin
👍 1
🙂 1
v
Yeah this is the standard behavior using NavigationComponent. You should keep your data in a scoped ViewModel and observe it from view/fragment. This way even when navigating back you will present them with the data they’ve left the screen.
👍🏼 1
m
@Viktor Petrovski Thank you 🙂