Foggy day
Android - getSupportFragmentManager, getChildFragmentManager 본문
It is necessary to seperate the use of 'getSupportFragmentManager()' and 'getChildFragmentManager()'.
If you have Activity "A" and Fragment "A-1" in "A", you should use getSupportFragmentManager() when you manage "A-1". getSupportFragmentManager() need activity.
But If you have Fragment "B", "C" in "A-1", you shoud use getChildFragmentManager() when you manage "B", "C".
If you work in fragment ", getChildFragmentManager() would not need activity.
For example,
activity.getSupportFragmentManager().beginTransaction()
.replace({container}, {fragment})
.commitAllowingStateLoss();
getChildFragmentManager().beginTransaction()
.replace({container}, {fragment})
.commitAllowingStateLoss();
'Android' 카테고리의 다른 글
Android(Kotlin) - RxKotlin -2 : Observable (0) | 2021.03.23 |
---|---|
Android(Kotlin) - RxKotlin -1 : PublishSubject (0) | 2021.03.23 |
Android(Kotlin) - question example using assets file - 2 (0) | 2021.03.14 |
Android(Kotlin) - question example using assets file - 1 (0) | 2021.03.14 |
Android(안드로이드) - EventBus Example (0) | 2021.03.10 |