Android JetPack: easy navigation with the new Navigation Controller
In the past few years implementing in-app navigation was always a pain. Google wants to change that and with this talk, we'll explore the new architecture component included in Android JetPack: The Navigation Controller.
and real solution to manage a common problem like Navigation • Navigation is “hard” and there are a lot things that you have to solve by your own • A lot of boilerplate code = A LOT of bugs and crash
<navigation> is the root node of the navigation graph • <navigation> can contains one or more destination represented by <activity> or <fragment> • app:startDestination is an attribute which controls what destination is launched by default when the user first opens the app.
tools:layout="@layout/fragment_home" /> </navigation> • android:id is the ID of the fragment that you can use to destination elsewhere in xml or code • android:name is your fragment class that will be instantiated when you navigate to that destination • tools:layout defines the layout xml file that should be shown in the graph editor
android:name=“androidx.navigation.fragment.NavHostFragment" ... /> <android.support.design.widget.BottomNavigationView android:id="@+id/bottomNavigationView" app:menu="@menu/bottom_navigation_main" /> </android.support.constraint.ConstraintLayout> Uses the same IDs of the destinations defined in the Navigation Graph res/layout/activity_main.xml KF