# Navigation
1. Create a resource file which resource type is Navigation

2. Android studio will help us to add dependency


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

Add two destinations like this

Add an action from 1 to 2

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

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)
}
}
```