Getting Started with the Navigation Component


Introduction

Navigation component is an API or tool in Android that makes it much easier to create, manage and edit fragment transition flows and deep linking, and many more throughout the entire application. Before the Navigation component, navigation tasks in an application were handled manually. You can add a listener for whatever UI element you want to trigger or an open and for navigation action or launching an intent to show a new activity Or transition of a Fragment.

You also need to handle onbackpressed, when the user clicks on the device’s Back button. You need to handle events and open the last fragment when the user presses the back button in the application.

With the help of the Navigation component, we have standard APIs, also we can see visuals of the navigation graph in IDE, which helps us to make the entire process clearer, easier, and more consistent. you can design navigation graphs by using a designing tool. Then you need to add the code which connects user interaction in your app with different actions of your app.

Let’s see what it exactly looks like in the IDE and in the code. Let’s make an application.

Setup

Getting started with the Android Studio. You need to add navigation fragments and UI libraries to your project. They are available via the google() repository.

implementation 'android.arch.navigation:navigation-fragment:1.0.0-alpha01'
implementation 'android.arch.navigation:navigation-ui:1.0.0-alpha01'

There is an optional step of including the safeargs navigation Gradle plugin. This plugin helps to generate code that allows type-safe access to properties used in argument capsules. You need to add the plugin to your project-level build.gradle classpath.

buildscript {

Continue Reading: Android Navigation Component


Comments

Popular posts from this blog

Why React Native is the Way Forward for Startups?

An Introduction to Creating Games and NFT Art with Unreal Engine

xCode 13 new features