Notice
Recent Posts
Recent Comments
Link
ยซ   2025/07   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐ŸŒฑ dreaming DiNO

[Kotlin] Navigation safeargs ์ถ”๊ฐ€ํ•˜์—ฌ back button ์ฒ˜๋ฆฌ (popup, stack ์•ˆ์Œ“์ด๋„๋ก) ๋ณธ๋ฌธ

Android

[Kotlin] Navigation safeargs ์ถ”๊ฐ€ํ•˜์—ฌ back button ์ฒ˜๋ฆฌ (popup, stack ์•ˆ์Œ“์ด๋„๋ก)

MK_____ 2023. 1. 31. 10:39

1. ๋„ค๋น„๊ฒŒ์ด์…˜ ํ™”๋ฉด์ด๋™: actionId๋กœ ์„ค์ •

Navigation.findNavController(binding.root).navigate(ChangePwFragmentDirections.actionChangePwFragmentToConfigFragment())

 

2. ํžˆ์Šคํ† ๋ฆฌ ์ง€์šธ Fragment, true ์„ค์ •

 

FragmentDirections ๊ฐ€ ์•ˆ๋‚˜์˜ฌ ๋•Œ 

Project gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
    	// args ์ถ”๊ฐ€
        def nav_version = "2.5.3"
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
    }
}

plugins {
    id 'com.android.application' version '7.3.1' apply false
    id 'com.android.library' version '7.3.1' apply false
    id 'org.jetbrains.kotlin.android' version '1.8.0' apply false
    id 'androidx.navigation.safeargs' version '2.5.3' apply false // args ์ถ”๊ฐ€
}

 

App module gradle

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'androidx.navigation.safeargs' // ์ถ”๊ฐ€
}

 

์ถœ์ฒ˜: https://devlopsquare.tistory.com/13