Join Slack
Powered by
Hi. how do i use jetpack composes setContent {} in...
# compose
j
Jrichards1408
11/10/2020, 11:29 AM
Hi. how do i use jetpack composes setContent {} inside a fragment?
✅ 1
a
Andrey Kulikov
11/10/2020, 11:32 AM
``class MyFragment : Fragment() {` `override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ) = ComposeView(requireContext()).apply { setContent() { Text("Hi") } } ) }``
j
Jrichards1408
11/10/2020, 11:33 AM
thanks
f
Fudge
11/10/2020, 11:38 AM
Or just .setContent{} instead of .apply{setContent(){}}
j
Jrichards1408
11/10/2020, 11:38 AM
sweet ok thanks
w
wisdom
11/10/2020, 12:02 PM
Helpful
a
Adam Powell
11/10/2020, 2:52 PM
apply is important here because the onCreateView function must return a View
3
Views
Open in Slack
Previous
Next