Mario Adam
04/21/2023, 1:04 PMCard
composable?muthuraj
04/21/2023, 6:32 PMAndroidView(modifier = Modifier.padding(it), factory = { context ->
FragmentContainerView(context).apply {
id = fragmentId
activity.supportFragmentManager
.beginTransaction()
.add(fragmentId, YourFragment())
.commit()
}
}, update = {
})
// To remove the fragment when this composable is removed.
DisposableEffect(Unit) {
onDispose {
activity.supportFragmentManager
.findFragmentById(fragmentId)
?.let { fragment ->
activity.supportFragmentManager
.commit {
remove(fragment)
}
}
}
}
}
You can use fragment inside any composable like thisAlbert Chang
04/22/2023, 6:25 AM