Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Collections Function
- layout_constrainedHeight
- DataBinding
- layout_constrainedWidth
- WorkManager
- multipart
- Room
- Retrofit2
- DialogFragment
- 화면 회전
- NumberPIcker
- Navigation
- Lifecycle
- SSAID
- findNavController
- BottomSheetDialogFragment
- http
- todo
- 생명주기
- Load failed
- gradle plugin
- ThreeTen Backport
- json
- log
- studywithme
- kotlin
- 기기고유값
- Popup menu background color
- RecyclerView
- Android
Archives
- Today
- Total
chacha's
🔀 Dialog에서 findNavController 접근 못 하는 문제 본문
Why Dialog does not have a NavController [Missing]? - stack overflow
를 참고하여 작성한 글입니다.
binding.repeatSettingOkBtn.setOnClickListener { view ->
view.findNavController().navigate(
RepeatSettingDialogFragmentDirections.actionRepeatSettingDialogToRepeatSchedule(repeatInfo))
}
DialogFragment에서 navigation을 이용하여 이동하려고 NavController에 접근하면 아래와 같은 에러를 만났습니다.
java.lang.IllegalStateException: View com.google.android.material.button.MaterialButton{...} does not have a NavController set
at androidx.navigation.Navigation.findNavController(Navigation.java:84)
at androidx.navigation.ViewKt.findNavController(View.kt:28)
🔻 DialogFragment는 NavController의 뷰 계층 구조와 완전히 분리된 창에서 동작하기 때문에 NavHostFragment.findNavController(this)을 사용하여 접근해야 합니다. 여기서 this는 DialogFragment() 입니다.
binding.repeatSettingOkBtn.setOnClickListener { view ->
NavHostFragment.findNavController(this).navigate(
RepeatSettingDialogFragmentDirections.actionRepeatSettingDialogToRepeatSchedule(repeatInfo))
}
'Android > TIL' 카테고리의 다른 글
| Gson을 이용하여 Assets에 있는 JSON 파일 읽기 (0) | 2021.08.09 |
|---|---|
| 🕶 Glide 이용할 때 Http URL 사용 시 화면 안 보임 (0) | 2021.08.07 |
| 💣 Button에 Drawable 적용 안 되는 오류 (1) | 2021.06.14 |
| 🧨 [ NumberPicker - Error : ] ArrayIndexOutOfBoundsException (0) | 2021.06.13 |
| 🎨 Number/Time Picker Divider 색상 변경 (0) | 2021.06.12 |
Comments