Hi. how do i use jetpack composes setContent {} in...
# compose
j
Hi. how do i use jetpack composes setContent {} inside a fragment?
1
a
``class MyFragment : Fragment() {` `override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) = ComposeView(requireContext()).apply { setContent() { Text("Hi") } } ) }``
j
thanks
f
Or just .setContent{} instead of .apply{setContent(){}}
j
sweet ok thanks
w
Helpful
a
apply is important here because the onCreateView function must return a View