본문 바로가기
Android

NavController 연속 클릭시 오류

by th_bigLight 2020. 7. 6.

 

 

버튼을 연속해서 두번 누르면 발생하는 에러 ㅠ

안드로이드 NavController 를 사용하는 도중 에러를 2개나 발견했다...

1. 버튼을 연속해서 2번 이상 빠르게 누르는 경우

2. popUp() 및 pupBackStack()으로 이동하는 경우

 

두 가지 모두 하나의 button이나 view가 여러가지 경우로 동작하는 경우 발생했다.

ex) 변수 userStatus가 login상태면 회원정보로. logout상태면 login화면으로 이동하는 경우 등

 

stackoverflow에 검색했을 때 크게 2가지 답안을 찾았다.

1. 버튼을 클릭할 때 enable = false를 걸어버린다

2. 처음 누른 시간과 2번째 누른 시간을 계산해서 해결한다.

 

1번 장점 = 매우 간단함.

단점 = Dialog에서 사용 불가 (다시 enable = true를 해줘야 하는데 같은 오류 반복)

2번 장점 = 복잡

장점 = 어디서든 사용 가능.

 

https://stackoverflow.com/questions/51060762/illegalargumentexception-navigation-destination-xxx-is-unknown-to-this-navcontr

 

IllegalArgumentException: navigation destination xxx is unknown to this NavController

I am having issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another, I get this weird error: java.lang.IllegalArgumentException: navigation

stackoverflow.com

 

 

댓글