I have a ListFragment that has a recyclerview and onClick on any items opens the DetailsFragment. The details fragment contains another recyclerview on the bottom that shows "MORE ITEMS". Now onClick on any of these items should open the DetailsFragment for that particular item. Basically the fragment needs to be refreshed.
In the past, I would just replace fragment using fragmentManager. How do I go about refreshing the fragment? How can I create an action that points to the same fragment?
So when you click your Button , find the Fragment you want to refresh by its tag, and then call your refresh method.
The onResume() get called always before the fragment is displayed. Even when the fragment is created for the first time . So you can simply move your from onViewCreated() to onResume .
A Fragment represents a reusable portion of your app's UI. A fragment defines and manages its own layout, has its own lifecycle, and can handle its own input events. Fragments cannot live on their own--they must be hosted by an activity or another fragment.
Creating an action from DetailsFragment to DetailsFragment and navigating to this action worked as mentioned by Alex
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With