I have tried multiple ways to achieve navigation
Have a look at this class and for full source See this
Android studio recommend FragmentContainerView to be used for Navigation
purpose. I simply want to show two fragments one is the PhotosFragment
and the other is PhotoDetailFragment
using Navigation component.
nav_graph.xml
<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/photosFragment">
<fragment android:id="@+id/photosFragment"
android:name="gallery.app.architecture.ui.photos.PhotosFragment"
tools:layout="@layout/item_photo">
<action android:id="@+id/action_photosFragment_to_photoDetailFragment"
app:destination="@id/photoDetailFragment" app:enterAnim="@anim/slide_in_right"
app:exitAnim="@anim/slide_out_left" app:popEnterAnim="@anim/slide_in_left"
app:popExitAnim="@anim/slide_out_right"/>
</fragment>
<fragment android:id="@+id/photoDetailFragment"
android:name="gallery.app.architecture.ui.photos.PhotoDetailFragment"
tools:layout="@layout/item_photo">
<argument android:name="imageUrl" app:argType="string"/>
<argument android:name="userName" app:argType="string"/>
<argument android:name="tags" app:argType="string"/>
</fragment>
</navigation>
I simply want to show two fragment one with PhotosFragment(List of photos) and on Click on any photo . Move to PhotoDetailFragment.
Latest code is pushed to Github along with it's link share above.When I test fragment individually, it's working correct. but navigation component not working as it should be.
Issue Resolved MainActivity with Navigation doesn't work with binding.