`I am trying to create an application where I am using SingleActivity and rest fragments, The problem I am facing is that I am using and <com.google.android.material.bottomnavigation.BottomNavigationView/> in my activity_main xml and in my MainActivity I have create navigation clicks. As I have 4 items in my bottom navigation I have assigned a navigation on every item click and it works
the solution I am looking for is Suppose I have Fragment A , B , C and D as the 4 fragments I have alloted to itemclick
for instance I am on Fragment A and from there I navigate to Fragment A1 and then to Fragment A2 now I click on Fragment B from bottom navigation and My Fragment B appears now when I click on Fragment A on bottomnavigation it should show A2 instead of A and that where I left my last navigation and when I reselect the A again it clears the stack of navigations and Fragment A appears
P.S I am using navigation grapgh directions for moving A to A1 and to A2`
<fragment
android:id="@+id/fragmentMain"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/white"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottomNavigation"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/navigation_graph" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:stretchColumns="true"
android:visibility="gone"
app:itemBackground="?android:attr/selectableItemBackgroundBorderless"
app:itemTextColor="@color/theme"
app:labelVisibilityMode="labeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="@menu/bottom_nav_menu" />