๋ก๊ทธ ํ์ธ
java.lang.IllegalStateException: Can't access the Fragment View's LifecycleOwner when getView() is null i.e., before onCreateView() or after onDestroyView()
ํ๋๊ทธ๋จผํธ์ onCreate() ์์์ getViewLifeCycleOwner() ๋ฅผ ํธ์ถํด์ ๋ฐ์ํ ์ด์์ด๋ค.
1.
Fragment.java์ getViewLiveCycleOwner()๊ฐ ๋ฐํํ๋ ๋ณ์๋ฅผ ํ์ธํ๋ค.
// This is initialized in performCreateView and unavailable outside of the
// onCreateView/onDestroyView lifecycle
@Nullable FragmentViewLifecycleOwner mViewLifecycleOwner;
2.
ํ๋๊ทธ๋จผํธ์ ๋ผ์ดํ์ฌ์ดํด์ ํ์ธํ๋ค.
์ฃผ์๊ณผ ํ๋๊ทธ๋จผํธ ๋ทฐ ๋ผ์ดํ์ฌ์ดํด์ ๋ณด๋ onCreateView() ์ด์ ์ onCreate()์์ ํ๋๊ทธ๋จผํธ์ view lifecycler owner๋ฅผ ํธ์ถํ ๋ด ์๋ชป์ด ๋ง๋ค.
-> ํ๋๊ทธ๋จผํธ์ ๋ผ์ดํ์ฌ์ดํด๊ณผ ํ๋๊ทธ๋จผํธ ๋ทฐ์ ๋ผ์ดํ์ฌ์ดํด์ ๋ณ๊ฐ๋ผ๋ ๊ฒ์ ์์ผ๋ก๋ ์์ง ์๊ธฐ๋ฅผ.
'๋น ๊ตฌ๋ฉ ์ฑ์ฐ๊ธฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Programming] Backpressure (0) | 2021.03.02 |
---|---|
[Kotlin Coroutines] Channels (0) | 2021.03.02 |
[Kotlin Coroutines] ObsoleteCoroutinesApi (0) | 2021.02.24 |
[Android] AndroidManifest <receiver> (0) | 2021.02.23 |
[Android] android.intent.action.MY_PACKAGE_REPLACED (0) | 2021.02.23 |