Merhawifissehaye
06/12/2020, 8:30 PMsetContent
doesn't seem to be available outside of an Activity? I also learned in a comment inside this stackoverflow question that there is a work in progress to add support for Fragments. Are there any updates on that? Or else what options do I have to be able to use compose inside fragments?Zach Klippenstein (he/him) [MOD]
06/12/2020, 8:44 PMFrameLayout
as your content view and then call setContent
on the FrameLayout
.Andrey Kulikov
06/12/2020, 9:05 PMabstract class ComposableFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
) = FrameLayout(requireContext()).apply {
setContent(Recomposer.current()) {
Content()
}
}
@Composable
abstract fun Content()
}
Javier
06/12/2020, 9:23 PMLeland Richardson [G]
06/12/2020, 9:27 PMJavier
06/12/2020, 9:28 PMLeland Richardson [G]
06/12/2020, 9:30 PMJavier
06/12/2020, 10:03 PMMerhawifissehaye
06/13/2020, 10:41 AMcomposeOptions {
kotlinCompilerVersion "1.3.70-dev-withExperimentalGoogleExtensions-20200424"
kotlinCompilerExtensionVersion "0.1.0-dev13"
}
I am on a multi module project, and I have added the option to both build.gradle files.