Hello everyone. I have an application written in J...
# compose
a
Hello everyone. I have an application written in Jetpack Compose (full, without fragments) and now i need to plug in fragment and can't rewrite it. Is there any way to do that? (even hacky)
c
You can wrap your
Fragment
into a composable. Create an XML file _my_fragment.xml_
Copy code
<androidx.fragment.app.FragmentContainerView
          xmlns:android="<http://schemas.android.com/apk/res/android>"
          xmlns:app="<http://schemas.android.com/apk/res-auto>"
          android:id="@+id/fragment_container_view"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.example.MyFragment"
          android:tag="my_tag">
   </androidx.fragment.app.FragmentContainerView>
Then you can use it in Compose:
Copy code
AndroidViewBinding(MyFragmentBinding::inflate)
You have use
FragmentActivity
and enable view binding for this.
a
Wow thanks!
a
AndroidViewBinding unresolved
Maybe i missed some dependencies?
I found androidx.compose.ui:ui-viewbinding thank you
a
Can I ask why you want to convert it to fragments? I have to decide which options(fragment, without fragment) would be better for new project.
a
We prefer to use clean compose because it has multiplatform implementation when fragment is only android implementation, but now we use third party applications which has react native implementation and they provides fragments to us
👍 1