-
본문으로 바로가기

출처: https://developer.android.com/guide/navigation/navigation-pass-data?hl=ko  (MAIN)

https://cocococo.tistory.com/entry/Kotlin-Fragment-Navigation-%ED%99%94%EB%A9%B4-%EC%A0%84%ED%99%98-%EB%B0%A9%EB%B2%95

 

  • 번들 객체로 대상 간 데이터 전달
     
    val bundle = bundleOf("amount" to amount)
    view.findNavController().navigate(R.id.confirmationAction, bundle)
    
    수신 대상 코드에서 getArguments() 메서드를 사용하여 Bundle을 검색하고 그 콘텐츠를 사용하세요.
  •  
    val tv = view.findViewById<TextView>(R.id.textViewAmount)
    tv.text = arguments?.getString("amount")
  • Gradle을 사용하지 않는 경우 Bundle 객체를 사용하여 대상 간에 계속 인수를 전달할 수 있습니다. 아래에서와 같이 Bundle 객체를 만들고 navigate()를 사용해 대상에 전달합니다.

시작 대상에 데이터 전달

반응형