[AAC] Navigation - 1

dwjeongยท2023๋…„ 11์›” 15์ผ
0

์•ˆ๋“œ๋กœ์ด๋“œ

๋ชฉ๋ก ๋ณด๊ธฐ
17/28
post-custom-banner

๐Ÿ”Ž ๋„ค๋น„๊ฒŒ์ด์…˜

์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ ๋‚ด์—์„œ ์„œ๋กœ ๋‹ค๋ฅธ ์ฝ˜ํ…์ธ  ํ™”๋ฉด๋“ค ์‚ฌ์ด๋ฅผ ์ด๋™ํ•˜๊ณ  ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ์ƒํ˜ธ์ž‘์šฉ์„ ๋‚˜ํƒ€๋ƒ„.

๐Ÿ“ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ปดํฌ๋„ŒํŠธ ์ฃผ์š” ๊ตฌ์„ฑ

  1. Navigation graph
    ๋ชจ๋“  ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ด€๋ จ ์ •๋ณด๋ฅผ ํ•œ ๊ณณ์— ์ง‘์ค‘์‹œํ‚จ xml ๋ฆฌ์†Œ์Šค. ์•ฑ ๋‚ด ๊ฐ๊ฐ์˜ ๋ชฉ์ ์ง€๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ํ†ตํ•ด ์ด๋™๊ฐ€๋Šฅํ•œ ๊ฒฝ๋กœ๋„ ํฌํ•จ๋จ.

  2. NavHost
    ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์—์„œ ๋ชฉ์ ์ง€๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋นˆ ์ปจํ…Œ์ด๋„ˆ. ๋„ค๋น„๊ฒŒ์ด์…˜ ์ปดํฌ๋„ŒํŠธ์—๋Š” fragment ๋ชฉ์ ์ง€๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๊ธฐ๋ณธ NavHost๋ฅผ ๊ตฌํ˜„ํ•œ NavHostFragment๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์Œ.

  3. NavController
    NavHost ๋‚ด์—์„œ ์•ฑ ๋„ค๋น„๊ฒŒ์ด์…˜์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฐ์ฒด. NavController๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ํ†ตํ•ด ์ด๋™ํ•  ๋•Œ NavHost์—์„œ ๋ชฉ์ ์ง€ ์ปจํ…์ธ ๋ฅผ ๊ต์ฒดํ•˜๋Š” ์—ญํ• ์„ ๋‹ด๋‹น.

์•ฑ์„ ํ†ตํ•ด ์ด๋™ํ•˜๋Š” ๋™์•ˆ NavController์—๊ฒŒ ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์˜ ํŠน์ • ๊ฒฝ๋กœ๋ฅผ ๋”ฐ๋ผ ์ด๋™ํ•˜๊ฑฐ๋‚˜ ํŠน์ • ๋ชฉ์ ์ง€๋กœ ์ง์ ‘ ์ด๋™ํ•˜๊ณ  ์‹ถ๋‹ค๊ณ  ์•Œ๋ฆฌ๋ฉด NavController๋Š” NavHost์—์„œ ์ ์ ˆํ•œ ๋ชฉ์ ์ง€๋ฅผ ํ‘œ์‹œํ•จ.


  • ์žฅ์ 
  1. Fragment ํŠธ๋ž™์žญ์…˜ ์ฒ˜๋ฆฌ
  2. ์˜ฌ๋ฐ”๋ฅธ Up and Back ์•ก์…˜ ์ฒ˜๋ฆฌ
  3. ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ฐ ์ „ํ™˜์— ๋Œ€ํ•œ ํ‘œ์ค€ํ™”๋œ ๋ฆฌ์†Œ์Šค ์ œ๊ณต
  4. ๋”ฅ๋งํฌ ๊ตฌํ˜„ ๋ฐ ์ฒ˜๋ฆฌ
  5. ์ตœ์†Œํ•œ์˜ ์ถ”๊ฐ€ ์ž‘์—…์œผ๋กœ ๋‚ด๋น„๊ฒŒ์ด์…˜ ๋“œ๋กœ์–ด ๋ฐ bottom navigation๊ณผ ๊ฐ™์€ ๋‚ด๋น„๊ฒŒ์ด์…˜ UI ํŒจํ„ด ํฌํ•จ.
  6. Safe Args๋ฅผ ํฌํ•จํ•œ ๋ฐ์ดํ„ฐ ์ „๋‹ฌ ๋ฐ ์•ˆ์ „์„ฑ์„ ์ œ๊ณตํ•˜๋Š” Gradle ํ”Œ๋Ÿฌ๊ทธ์ธ.
  7. ViewModel ์ง€์› ์ œ๊ณต - ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์— ViewModel์„ ์ง€์ •ํ•˜์—ฌ ๊ทธ๋ž˜ํ”„ ๋ชฉ์ ์ง€ ๊ฐ„์— UI ๊ด€๋ จ ๋ฐ์ดํ„ฐ๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ์Œ.



โญ ์ฐธ๊ณ 
Android 13์—์„œ๋Š” Android ๊ธฐ๊ธฐ์šฉ Navigation ์ปดํฌ๋„ŒํŠธ์™€ ํ•จ๊ป˜ ์ž‘๋™ํ•˜๋Š” predictive back navigation์ด ๋ฐœํ‘œ๋˜์—ˆ์Œ. ํ–ฅํ›„ ๋ฆด๋ฆฌ์Šค์—์„œ ์˜ˆ์ƒ์น˜ ๋ชปํ•œ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๊ฐ€๋Šฅํ•œ ๋นจ๋ฆฌ predictive back navigation์„ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ๊ถŒ์žฅ๋จ.




๐Ÿ“ ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„ ์ƒ์„ฑ

๋„ค๋น„๊ฒŒ์ด์…˜์€ ์‚ฌ์šฉ์ž๊ฐ€ ์ด๋™ํ•  ์ˆ˜ ์žˆ๋Š” ์•ฑ์˜ ๋ชฉ์ ์ง€ ์‚ฌ์ด์— ๋ฐœ์ƒํ•จ. ๋ชฉ์ ์ง€๋Š” ์•ก์…˜์„ ํ†ตํ•ด ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์Œ.

Navigation graph๋Š” ๋ชจ๋“  ๋ชฉ์ ์ง€์™€ ์•ก์…˜์„ ํฌํ•จํ•˜๋Š” ๋ฆฌ์†Œ์Šค ํŒŒ์ผ. ์ด ๊ทธ๋ž˜ํ”„๋Š” ์•ฑ์˜ ๋ชจ๋“  ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ฒฝ๋กœ๋ฅผ ๋‚˜ํƒ€๋ƒ„.

์œ„์˜ ๊ทธ๋ฆผ์—์„œ
1. ๋ชฉ์ ์ง€๋Š” ์•ฑ ๋‚ด์˜ ์„œ๋กœ ๋‹ค๋ฅธ ์ปจํ…์ธ  ์˜์—ญ์„ ๋‚˜ํƒ€๋ƒ„.
2. ์•ก์…˜์€ ์‚ฌ์šฉ์ž๊ฐ€ ๋”ฐ๋ฅผ ์ˆ˜ ์žˆ๋Š” ๊ฒฝ๋กœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ชฉ์ ์ง€ ๊ฐ„์˜ ๋…ผ๋ฆฌ์ ์ธ ์—ฐ๊ฒฐ.

๐Ÿ’ก ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„๋ฅผ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•œ ๋‹จ๊ณ„
1. ํ”„๋กœ์ ํŠธ ์ฐฝ์—์„œ res ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์šฐํด๋ฆญํ•œ ํ›„ New > Android Resource File์„ ์„ ํƒ.
2. File name ํ•„๋“œ์— "nav_graph"์™€ ๊ฐ™์€ ์ด๋ฆ„์„ ์ž…๋ ฅ.
3. Resource type ๋“œ๋กญ๋‹ค์šด ๋ชฉ๋ก์—์„œ Navigation์„ ์„ ํƒํ•œ ํ›„ OK ํด๋ฆญ.



๐Ÿ“ ๋„ค๋น„๊ฒŒ์ด์…˜ ์—๋””ํ„ฐ

๋„ค๋น„๊ฒŒ์ด์…˜ ์—๋””ํ„ฐ์—์„œ ์‹œ๊ฐ์ ์œผ๋กœ ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„๋ฅผ ํŽธ์ง‘ํ•˜๊ฑฐ๋‚˜ ๊ธฐ๋ณธ XML์„ ํŽธ์ง‘.

์œ„ ๊ทธ๋ฆผ์—์„œ
1. Destinations panel: ๋‚ด๋น„๊ฒŒ์ด์…˜ ํ˜ธ์ŠคํŠธ ๋ฐ ํ˜„์žฌ ๊ทธ๋ž˜ํ”„ ์—๋””ํ„ฐ์— ์žˆ๋Š” ๋ชฉ์ ์ง€๋ฅผ ๋‚˜์—ด.
2. Graph Editor: ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์˜ ์‹œ๊ฐ์  ํ‘œํ˜„์ด ์žˆ๋Š” ๊ณณ.
3. Attributes: ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์—์„œ ํ˜„์žฌ ์„ ํƒ๋œ ํ•ญ๋ชฉ์— ๋Œ€ํ•œ ์†์„ฑ ํ‘œ์‹œ.

Text ํƒญ์„ ํด๋ฆญํ•˜๋ฉด XML์ด ๋ณด์ž„.

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/nav_graph">

</navigation>

<navigation> element๋Š” ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์˜ root.
๋ชฉ์ ์ง€ ๋ฐ ์•ก์…˜์„ ์ถ”๊ฐ€ํ•  ๋•Œ์˜ element์ธ <destination>๊ณผ <action>์ด ์ž์‹ ์š”์†Œ๊ฐ€ ๋จ.
์ค‘์ฒฉ๋œ ๊ทธ๋ž˜ํ”„๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ํ•ด๋‹น ๊ทธ๋ž˜ํ”„๋Š” ์ž์‹ <navigation>์ด ๋จ.



๐Ÿ“ ์•กํ‹ฐ๋น„ํ‹ฐ์— NavHost ์ถ”๊ฐ€

๋„ค๋น„๊ฒŒ์ด์…˜ ํ˜ธ์ŠคํŠธ๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ํ†ตํ•ด ์ด๋™ํ•˜๋Š” ๋™์•ˆ ๋ชฉ์ ์ง€๊ฐ€ ๊ต์ฒด๋˜๋Š” ๋นˆ ์ปจํ…Œ์ด๋„ˆ.
๋„ค๋น„๊ฒŒ์ด์…˜ ํ˜ธ์ŠคํŠธ๋Š” NavHost์—์„œ ํŒŒ์ƒ๋˜์–ด์•ผ ํ•จ. ๋„ค๋น„๊ฒŒ์ด์…˜ ์ปดํฌ๋„ŒํŠธ์˜ ๊ธฐ๋ณธ NavHost ๊ตฌํ˜„์ธ NavHostFragment๋Š” ํ”„๋ž˜๊ทธ๋จผํŠธ ๋ชฉ์ ์ง€๋ฅผ ๊ต์ฒดํ•˜๋Š” ์ž‘์—…์„ ์ฒ˜๋ฆฌํ•จ.



โญ๏ธ ๋„ค๋น„๊ฒŒ์ด์…˜ ์ปดํฌ๋„ŒํŠธ๋Š” ์ฃผ๋กœ ์—ฌ๋Ÿฌ ํ”„๋ž˜๊ทธ๋จผํŠธ ๋ชฉ์ ์ง€๋ฅผ ๊ฐ€์ง„ ํ•˜๋‚˜์˜ ๋ฉ”์ธ ์•กํ‹ฐ๋น„ํ‹ฐ๋ฅผ ๊ฐ€์ง„ ์•ฑ์„ ๋Œ€์ƒ์œผ๋กœ ์„ค๊ณ„๋˜์—ˆ์Œ. ๋ฉ”์ธ ์•กํ‹ฐ๋น„ํ‹ฐ๋Š” ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์™€ ๊ด€๋ จ์žˆ์œผ๋ฉฐ ํ•„์š”์— ๋”ฐ๋ผ ๋ชฉ์ ์ง€๋ฅผ ๊ต์ฒดํ•˜๋Š” ์ฑ…์ž„์ด ์žˆ๋Š” NavHostFragment๋ฅผ ํฌํ•จํ•จ.
์—ฌ๋Ÿฌ ์•กํ‹ฐ๋น„ํ‹ฐ ๋ชฉ์ ์ง€๋ฅผ ๊ฐ€์ง„ ์•ฑ์˜ ๊ฒฝ์šฐ ๊ฐ ์•กํ‹ฐ๋น„ํ‹ฐ๋Š” ์ž์ฒด ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋จ.



๐Ÿ“• XML์„ ํ†ตํ•ด NavHostFragment ์ถ”๊ฐ€

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.appcompat.widget.Toolbar
        .../>

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/nav_host_fragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"

        app:defaultNavHost="true"
        app:navGraph="@navigation/nav_graph" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        .../>

</androidx.constraintlayout.widget.ConstraintLayout>

  1. android:name ์†์„ฑ์—” NavHost ๊ตฌํ˜„ ํด๋ž˜์Šค ์ด๋ฆ„ ํฌํ•จ
  2. app:navGraph ์†์„ฑ์—” NavHostFragment๋ฅผ ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์— ์—ฐ๊ฒฐ. ๋‚ด๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„๋Š” ์‚ฌ์šฉ์ž๊ฐ€ ์ด NavHostFragment์—์„œ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ๋ชฉ์ ์ง€๋ฅผ ์ง€์ •
  3. app:defaultNavHost="true" ์†์„ฑ์€ NavHostFragment๊ฐ€ ์‹œ์Šคํ…œ Back ๋ฒ„ํŠผ์„ ๊ฐ€๋กœ์ฑ„๋„๋ก ํ•จ.



๐Ÿ“ ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ทธ๋ž˜ํ”„์— ๋ชฉ์ ์ง€ ์ถ”๊ฐ€

๊ธฐ์กด ํ”„๋ž˜๊ทธ๋จผํŠธ๋‚˜ ์•กํ‹ฐ๋น„ํ‹ฐ์—์„œ ๋ชฉ์ ์ง€ ์ƒ์„ฑ ๊ฐ€๋Šฅ. ๋˜ํ•œ ๋‚ด๋น„๊ฒŒ์ด์…˜ ์—๋””ํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ƒˆ ๋ชฉ์ ์ง€๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜ ๋‚˜์ค‘์— ํ”„๋ž˜๊ทธ๋จผํŠธ๋‚˜ ์•กํ‹ฐ๋น„ํ‹ฐ๋กœ ๋Œ€์ฒดํ•  ์ˆ˜ ์žˆ๋Š” ํ”Œ๋ ˆ์ด์Šคํ™€๋”๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Œ.

  1. ๋‚ด๋น„๊ฒŒ์ด์…˜ ์—๋””ํ„ฐ์—์„œ New Destination ์•„์ด์ฝ˜์„ ํด๋ฆญํ•œ ํ›„ Create new destination์„ ํด๋ฆญ.
  2. ๋‚˜ํƒ€๋‚˜๋Š” New Android Component ๋Œ€ํ™”์ƒ์ž์—์„œ ํ”„๋ž˜๊ทธ๋จผํŠธ๋ฅผ ๋งŒ๋“ฆ.



๐Ÿ“ ๋ชฉ์ ์ง€๋กœ ์ด๋™

๋ชฉ์ ์ง€๋กœ ์ด๋™ํ•˜๋Š” ๊ฒƒ์€ NavController๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ˆ˜ํ–‰๋˜๋ฉฐ, NavController๋Š” NavHost ๋‚ด์—์„œ ์•ฑ ๋„ค๋น„๊ฒŒ์ด์…˜์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ฐ์ฒด.

๊ฐ NavHost์—๋Š” ๊ณ ์œ ํ•œ NavController๊ฐ€ ์žˆ์Œ.

Kotlin:
Fragment.findNavController()
View.findNavController()
Activity.findNavController(viewId: Int)

Java:
NavHostFragment.findNavController(Fragment)
Navigation.findNavController(Activity, @IdRes int viewId)
Navigation.findNavController(View)


์œ„์˜ ๋ฉ”์†Œ๋“œ๋“ค ์ค‘ ํ•˜๋‚˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ NavController๋ฅผ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ์Œ.

FragmentContainerView๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ NavHostFragment๋ฅผ ๋งŒ๋“ค๊ฑฐ๋‚˜ FragmentTransaction์„ ํ†ตํ•ด ์ˆ˜๋™์œผ๋กœ NavHostFragment๋ฅผ ์•กํ‹ฐ๋น„ํ‹ฐ์— ์ถ”๊ฐ€ํ•  ๋•Œ, ์•กํ‹ฐ๋น„ํ‹ฐ์˜ onCreate()์—์„œ Navigation.findNavController(Activity, @IdRes int)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ NavController๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค๊ณ  ํ•˜๋ฉด ์‹คํŒจํ•  ์ˆ˜ ์žˆ์Œ.

๋Œ€์‹  ์ง์ ‘ NavController๋ฅผ NavHostFragment์—์„œ ๊ฐ€์ ธ์™€์•ผ ํ•จ.

val navHostFragment =
        supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
val navController = navHostFragment.navController



๐Ÿ“• Safe Args๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํƒ€์ž… ์•ˆ์ „์„ฑ ๋ณด์žฅ

๋ชฉ์ ์ง€ ์‚ฌ์ด๋ฅผ ์ด๋™ํ• ๋•Œ ๊ถŒ์žฅ๋˜๋Š” ๋ฐฉ๋ฒ•์€ Safe Args Gradle ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ. ์ด ํ”Œ๋Ÿฌ๊ทธ์ธ์€ ๊ฐ„๋‹จํ•œ ๊ฐ์ฒด ๋ฐ ๋นŒ๋” ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ๋ชฉ์ ์ง€ ๊ฐ„ ์•ˆ์ „ํ•œ ํ˜•์‹์˜ ๋‚ด๋น„๊ฒŒ์ด์…˜๊ณผ ์ธ์ž ์ „๋‹ฌ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•จ.

Safe Args๋ฅผ ํ™œ์„ฑํ™”ํ•˜๋ฉด ํ•ด๋‹น ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์ •์˜ํ•œ ๊ฐ ์•ก์…˜์— ๋Œ€ํ•œ ํด๋ž˜์Šค ๋ฐ ๋ฉ”์„œ๋“œ๋ฅผ ์ƒ์„ฑ.
Safe Args๋Š” ๋ชฉ์ ์ง€์— ๋Œ€ํ•œ ํด๋ž˜์Šค๋„ ์ƒ์„ฑ. ์ƒ์„ฑ๋œ ํด๋ž˜์Šค ์ด๋ฆ„์€ ๋ชฉ์ ์ง€ํด๋ž˜์Šค ์ด๋ฆ„ + Directions๋ผ๋Š” ๋‹จ์–ด์˜ ์กฐํ•ฉ.
(์˜ˆ: SpecifyAmountFragment ๊ฐ€ ๋ชฉ์ ์ง€์ผ ๊ฒฝ์šฐ SpecifyAmountFragmentDirections๊ฐ€ ์ƒ์„ฑ๋จ.)

์ƒ์„ฑ๋œ ํด๋ž˜์Šค์—” ๋ชฉ์ ์ง€์— ์ •์˜๋œ ๊ฐ ์•ก์…˜์— ๋Œ€ํ•œ ์ •์  ๋ฉ”์„œ๋“œ ํฌํ•จ. ์ด ๋ฉ”์„œ๋“œ๋Š” ์ •์˜๋œ ์•ก์…˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ธ์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๊ณ  navigate()์— ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๋Š” NavDirections ๊ฐ์ฒด ๋ฐ˜ํ™˜.

override fun onClick(view: View) {
    val action =
        SpecifyAmountFragmentDirections
            .actionSpecifyAmountFragmentToConfirmationFragment()
    view.findNavController().navigate(action)
}
post-custom-banner

1๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2023๋…„ 11์›” 15์ผ

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฐ ์ •๋ณด๋ฅผ ๋‚˜๋ˆ ์ฃผ์…”์„œ ์ข‹์•„์š”.

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ