새 대상 유형을 위한 지원 추가
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
NavController
유형은 하나 이상의 Navigator
객체를 사용하여 탐색 작업을 실행합니다. 기본적으로 NavController
는 ActivityNavigator
클래스와 중첩된 ActivityNavigator.Destination
클래스를 사용하여 다른 활동으로 이동하는 방식으로 탐색 그래프에서 떠나도록 지원합니다.
다른 유형의 대상으로 이동하려면 하나 이상의 추가적인 Navigator
객체를 NavController
에 추가해야 합니다. 예를 들어, 프래그먼트를 대상으로 사용한다면 NavHostFragment
는 자동으로 FragmentNavigator
클래스를 NavController
에 추가합니다.
새 Navigator
객체를 NavController
에 추가하려면 getNavigatorProvider()
메서드 다음에 addNavigator()
메서드를 사용합니다.
다음 코드는 CustomNavigator
객체를 NavController
에 추가하는 예를 보여줍니다.
Kotlin
val customNavigator = CustomNavigator()
navController.navigatorProvider += customNavigator
Java
CustomNavigator customNavigator = new CustomNavigator();
navController.getNavigatorProvider().addNavigator(customNavigator);
대부분의 Navigator
클래스에는 중첩된 대상 서브클래스가 있습니다. 이 서브클래스를 사용하여 대상에 고유한 추가 속성을 지정할 수 있습니다. 대상 서브클래스에 관한 자세한 내용은 적절한 Navigator
클래스의 참조 문서를 확인하세요.
추가 리소스
탐색에 관한 자세한 내용은 다음 추가 리소스를 참고하세요.
Codelab
동영상
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Add support for new destination types\n\nThe [`NavController`](/reference/androidx/navigation/NavController) type\nrelies on one or more\n[`Navigator`](/reference/androidx/navigation/Navigator) objects to perform\nthe navigation operation. By default, `NavController` supports leaving the\nnavigation graph by navigating to another activity using the\n[`ActivityNavigator`](/reference/androidx/navigation/ActivityNavigator)\nclass and its nested\n[`ActivityNavigator.Destination`](/reference/androidx/navigation/ActivityNavigator.Destination)\nclass.\n\nTo navigate to any other type of destination, one or more additional `Navigator`\nobjects must be added to the `NavController`. For example, when using fragments\nas destinations, the\n[`NavHostFragment`](/reference/androidx/navigation/fragment/NavHostFragment)\nautomatically adds the\n[`FragmentNavigator`](/reference/androidx/navigation/fragment/FragmentNavigator)\nclass to its `NavController`.\n\nTo add a new `Navigator` object to a `NavController`, use the\n[`getNavigatorProvider()`](/reference/androidx/navigation/NavController#getNavigatorProvider())\nmethod, followed by the\n[`addNavigator()`](/reference/androidx/navigation/NavigatorProvider#addNavigator(androidx.navigation.Navigator))\nmethod.\n\nThe following code shows an example of adding a `CustomNavigator` object to a\n`NavController`: \n\n### Kotlin\n\n```kotlin\nval customNavigator = CustomNavigator()\nnavController.navigatorProvider += customNavigator\n```\n\n### Java\n\n```java\nCustomNavigator customNavigator = new CustomNavigator();\nnavController.getNavigatorProvider().addNavigator(customNavigator);\n```\n\nMost `Navigator` classes have a nested destination subclass. This subclass can\nbe used to specify additional attributes unique to your destination. For more\ninformation about destination subclasses, see the reference documentation for\nthe appropriate [`Navigator`](/reference/androidx/navigation/Navigator)\nclass.\n\nAdditional resources\n--------------------\n\nTo learn more about navigation, see the following\nadditional resources.\n\n\u003cbr /\u003e\n\n### Codelabs\n\n\u003cbr /\u003e\n\n- [Learn Jetpack Navigation codelab](https://codelabs.developers.google.com/codelabs/android-navigation/index.html?index=..%2F..%2Findex#0)\n\n\u003cbr /\u003e\n\n### Videos\n\n\u003cbr /\u003e\n\n- [Android Jetpack: Manage UI navigation with Navigation Controller](https://www.youtube.com/watch?v=8GCXtCjtg40)"]]