galex
11/26/2023, 12:53 PMAndroidViewBinding
?
Obviously, as it is inflated by a View (Binding), it is inflated without arguments:
AndroidViewBinding(factory = ComposeDashboardMainBinding::inflate) {
val myFragment = composeDashboardContainerView.getFragment<DashboardMainFragment>()
myFragment.arguments = Bundle().apply {
putString("test-param", "Alex") // Not passed before onCreate and others
}
myFragment.setParams("Alex") // Calling a function does work
}
galex
11/26/2023, 3:14 PMAndroidView(factory = { context ->
FrameLayout(context).apply {
id = R.id.compose_test
supportFragmentManager.beginTransaction()
.add(R.id.compose_test, DashboardMainFragment().apply {
arguments = Bundle().apply {
putString("test-param", "Alex")
}
}, "FRAGMENT_TEST")
.commitNow()
}
}, onRelease = {
val fragment = supportFragmentManager.findFragmentByTag("FRAGMENT_TEST")
fragment?.let { it1 -> supportFragmentManager.beginTransaction().remove(it1).commitNow() }
},
modifier = Modifier.fillMaxSize()
)
Joseph Hawkes-Cates
10/08/2024, 2:50 PMAndroidFragment
API though and used that and got this to work immediately!galex
10/08/2024, 2:52 PM