Android Kotlin – Navigation Add Host Fragment and Connect Destinations with Actions

Screenshot 20181208 124245

On the activity’s layout XML file that you want to add Host Fragment, add the following code. <fragment android:id=”@+id/navHostFragment” android:name=”androidx.navigation.fragment.NavHostFragment” android:layout_width=”match_parent” android:layout_height=”match_parent” app:navGraph=”@navigation/navigation” app:defaultNavHost=”true” /> android:name – class name app:navGraph – which navigation resource to use app:defaultNavHost=”true” – intercepts the system Back button Now, go navigation.xml, switch to Design and add a new Destination by clicking the + symbol at the top To set it the first destination of the navigation click Set Start Destination To create an action, add a second destination, and then click the circle on the first destination and…

Android Kotlin – Navigation Add Host Fragment and Connect Destinations with Actions Read More