# Navigation 1. Create a resource file which resource type is Navigation ![](https://i.imgur.com/9QN1aQg.png) 2. Android studio will help us to add dependency ![](https://i.imgur.com/SZoysKl.png) ![](https://i.imgur.com/CrJEjyp.png) 3. Plug this xml code to your layout file which host view ```xml= <fragment android:id="@+id/my_nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" app:navGraph="@navigation/my_navigation" /> ``` 4. Go to my_navigation.xml press + button to add new destination ![](https://i.imgur.com/bWPyfVZ.png) Add two destinations like this ![](https://i.imgur.com/FK9oDcW.png) Add an action from 1 to 2 ![](https://i.imgur.com/15uyRYr.png) Xml will like this ```xml= <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/my_navigation" app:startDestination="@id/blankFragment1"> <fragment android:id="@+id/blankFragment1" android:name="com.tryusernavigatot.BlankFragment1" android:label="fragment_blank1" tools:layout="@layout/fragment_blank1" > <action android:id="@+id/action_blankFragment1_to_blankFragment2" app:destination="@id/blankFragment2" /> </fragment> <fragment android:id="@+id/blankFragment2" android:name="com.tryusernavigatot.BlankFragment2" android:label="fragment_blank2" tools:layout="@layout/fragment_blank2" /> </navigation> ``` 5. Now we got two fragment layout and kt file in project ![](https://i.imgur.com/g0n165K.png) 6. Add a button in fragment_blank1.xml to trig changing view ```xml= <Button android:id="@+id/goNextBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Go to next view"/> ``` 7. Add this code in BlankFragment1.kt ```kotlin= override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) goNextBtn.setOnClickListener { findNavController().navigate(R.id.action_blankFragment1_to_blankFragment2) } } ```