Reputation: 19
I want to refresh my fragment by clicking on its button. How to do it? I try to do it like this but old version of fragment appears on the top of the screen (picture is attached):
binding.checkAnswersButton.setOnClickListener {
requireFragmentManager().beginTransaction().apply {
replace(R.id.quizFragment, QuizFragment())
.commit()
}
}
Upvotes: 0
Views: 3165
Reputation: 294
This will refresh the fragment :
val ft = parentFragmentManager.beginTransaction()
ft.detach(this).attach(this).commit()
Upvotes: 0