Android Kotlin – Add Navigation Components and Create a Navigation Graph

First, you must set up the Navigation Component. Go to File > Settings. Click Experimental and then check Enable Navigation Editor, <span>Android Kotlin – Add Navigation Components and Create a Navigation Graph</span>, KandZ

Open Build.gradle (Project) and add a variable for navigation version

buildscript { 
   ext 
    { 
      navigationVersion = '1.0.0-alpha08' 
      ...
    }

, <span>Android Kotlin – Add Navigation Components and Create a Navigation Graph</span>, KandZ

Now open Build.gradle(App) and add the dependencies for Navigation:

dependencies {
    implementation "android.arch.navigation:navigation-fragment:$navigationVersion"
    implementation "android.arch.navigation:navigation-ui:$navigationVersion"

, <span>Android Kotlin – Add Navigation Components and Create a Navigation Graph</span>, KandZ

Sync Project with Gradle Files.

Add a Navigation Graph. Right-click on the res directory and select New > Android Resource File. Type a name in the File name field, such as “navigation”. Select Navigation from the Resource type drop-down list. Click OK.

, <span>Android Kotlin – Add Navigation Components and Create a Navigation Graph</span>, KandZ

Click Design. You will see the following

, <span>Android Kotlin – Add Navigation Components and Create a Navigation Graph</span>, KandZ

 

35190cookie-checkAndroid Kotlin – Add Navigation Components and Create a Navigation GraphAndroid Kotlin – Add Navigation Components and Create a Navigation Graph

Related posts