# FragmentNavigator.Extras.Builder

Artifact: [androidx.navigation:navigation-fragment](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/fragment/FragmentNavigator.kt+class:androidx.navigation.fragment.FragmentNavigator.Extras.Builder) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

*** ** * ** ***

<br />

```
class FragmentNavigator.Extras.Builder
```

<br />

*** ** * ** ***

Builder for constructing new `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` instances. The resulting instances are immutable.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder#Builder()()` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` | `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder#addSharedElement(android.view.View,kotlin.String)(sharedElement: https://developer.android.com/reference/android/view/View.html, name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Maps the given View in the current Fragment to the given transition name in the Fragment being navigated to. |
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` | `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder#addSharedElements(kotlin.collections.Map)(sharedElements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>)` Adds multiple shared elements for mapping Views in the current Fragment to transitionNames in the Fragment being navigated to. |
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` | `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder#build()()` Constructs the final `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` instance. |

## Public constructors

### Builder

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
Builder()
```

## Public functions

### addSharedElement

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
fun addSharedElement(sharedElement: View, name: String): FragmentNavigator.Extras.Builder
```

Maps the given View in the current Fragment to the given transition name in the Fragment being navigated to.

| Parameters |
|---|---|
| `sharedElement: https://developer.android.com/reference/android/view/View.html` | A View in the current Fragment to match with a View in the Fragment being navigated to. |
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The transitionName of the View in the Fragment being navigated to that should be matched to the shared element. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` | this `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentTransaction#addSharedElement(android.view.View,java.lang.String)` |   |

### addSharedElements

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
fun addSharedElements(sharedElements: Map<View, String>): FragmentNavigator.Extras.Builder
```

Adds multiple shared elements for mapping Views in the current Fragment to transitionNames in the Fragment being navigated to.

| Parameters |
|---|---|
| `sharedElements: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | Shared element pairs to add |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` | this `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras.Builder` |

### build

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigation#1.0.0)

```
fun build(): FragmentNavigator.Extras
```

Constructs the final `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` | An immutable `https://developer.android.com/reference/kotlin/androidx/navigation/fragment/FragmentNavigator.Extras` instance. |