Last active
November 30, 2022 11:31
-
-
Save kingjinho/f1acfc36eb0dc5f2607631197267beb1 to your computer and use it in GitHub Desktop.
Contructor of FragmentContainerView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//생성자 | |
internal constructor( | |
context: Context, | |
attrs: AttributeSet, | |
fm: FragmentManager | |
) : super(context, attrs) { | |
//생략된 부분에서 이름과 태그를 체크합니다. | |
... | |
if (name != null && existingFragment == null) { | |
if (id == View.NO_ID) { | |
val tagMessage = if (tag != null) " with tag $tag" else "" | |
throw IllegalStateException( | |
"FragmentContainerView must have an android:id to add Fragment $name$tagMessage" | |
) | |
} | |
//Fragment 생성 | |
val containerFragment: Fragment = | |
fm.fragmentFactory.instantiate(context.classLoader, name) | |
//생성된 Fragment의 onInflate(...) 호출 | |
containerFragment.onInflate(context, attrs, null) | |
fm.beginTransaction() | |
.setReorderingAllowed(true) | |
.add(this, containerFragment, tag) | |
.commitNowAllowingStateLoss() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment