I need reload fragment after this process
Go from Fragment A to Fragment B and go from Fragment B to Fragment C, then do the registration process, and after the registration is correct, popBackStack Fragment A and my Fragment A will be reloaded.
My main problem is that Fragment A is not reloaded
Please help me
Asked
Active
Viewed 979 times
0

Asghar Hosseini
- 239
- 1
- 5
- 14
-
could you explain what you mean by reloaded – Narendra_Nath Jan 03 '22 at 08:57
-
I added an image, I hope you understand what I mean – Asghar Hosseini Jan 03 '22 at 09:03
1 Answers
1
you can use navigation component library for solve this problem!
this will be your nav_graph.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nav_graph"
app:startDestination="@id/AFragment">
<fragment
android:id="@+id/AFragment"
android:name="ir.inbo.navigationComponenetBug.AFragment"
android:label="AFragment"
tools:layout="@layout/fragment_a">
<argument
android:name="someLong"
app:argType="long" />
<action
android:id="@+id/action_AFragment_to_BFragment"
app:destination="@id/BFragment" />
</fragment>
<fragment
android:id="@+id/BFragment"
android:name="ir.inbo.navigationComponenetBug.BFragment"
android:label="BFragment"
tools:layout="@layout/fragment_b">
<argument
android:name="someLong"
app:argType="long" />
<action
android:id="@+id/action_BFragment_to_CFragment"
app:destination="@id/CFragment" />
</fragment>
<fragment
android:id="@+id/CFragment"
android:name="ir.inbo.navigationComponenetBug.CFragment"
android:label="CFragment"
tools:layout="@layout/fragment_c" >
<argument
android:name="someLong"
app:argType="long" />
<action
android:id="@+id/action_CFragment_to_AFragment"
app:destination="@id/AFragment"
app:popUpTo="@id/AFragment"
app:popUpToInclusive="true" />
</fragment>
</navigation>
and in AFragment you must move your logic to onViewCreated or onCreateView because of the fragment life cycle when you navigate from AFragment to Bfragment, Afragment's view will be destroyed and when you come back to Afragment from Cfragment, onViewCreated and onViewCreate will be called
and this is google example for your exact use case

Mobin Yardim
- 695
- 7
- 17