Check Mobile App
Read now
Start a Project

Navigation Component In Android

Save

In this blog, we will learn how to integrate or work with Navigation Component In Android. Before starting our topic, we will discuss Navigation in brief.

Navigation refers to the interaction section of the application, that allows users to navigate from one page to another page throughout the application. With the help of Android’s JetPack, we can create Navigation from simple UI (Buttons) to complex UI (Bottom Navigation, Navigation Drawer).

In this blog, we will demonstrate the Navigation Component by creating Bottom Navigation in-app and will see how the navigation component works.

1. Adding dependecies

In this step, we will add all the dependencies related to the Navigation component in our “build.gradle” file. Here, we have added only the Kotlin related dependencies, if you are working on Java, then can add Java-related dependencies. You can take references of the Developer console

2. Adding the Navigation Graph & Menus

We can create the Navigation Graph class under the resource folder and select the Navigation under the  Resource type drop-down list.
We can add the action to each fragment, so their click event works accordingly, we can see the graph related to the Navigation XML file in the Android studio in the design section.

Adding the Menus file for Bottom Navigation

We have added only 3 fragments for test purposes, you can add multiple as per your need.

3. Adding the click events and setting the Controllers

In this step, we will set up the final click events and controller with Navigation Component.

We will add following line of code to set the controller in main activity. Navigation component interanally deal with click events on the basis of the pages declared in the navigation Graph

Conclusion:

In this blog, you have learned about the Navigation Component In Android.

You can check the mentioned link for more information about  Navigation Component 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

The support is fast and do everything in their power to make it perfect. If you need customization it's also done right away. I had massive research to select Mobikul and now I'm sure it was the right one.

Igor Souza

Igor Souza

Talk to Sales

Global

Live Chat
Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home