I have two fragments: Fragment A contains a recyclerview of 5 article items and Fragment B contains the webview of the selected article in Fragment A.
Upon going back from Fragment B to A, my items in the recyclerview in Fragment A doubled. So basically, Fragment A is now showing duplicate items which are not what I want.
I tried to override the onResume
method in Fragment A like this but no luck:
override fun onResume() {
super.onResume()
arrayArticles.clear()
val articlesAdapter = TipsRecyclerAdapter(arrayArticles, this)
binding.tipsRecyclerView.layoutManager = LinearLayoutManager(context)
binding.tipsRecyclerView.adapter = articlesAdapter
}
PS: I am using the navigation component to navigate between fragments.