Hii, I'm working on google map cluster with custom infowindow and getting following error when i try to use ComposeView in the GoogleMap.InfoWindowAdapter class
Copy code
java.lang.IllegalStateException: Cannot locate windowRecomposer; View androidx.compose.ui.platform.ComposeView{d5f4b2c V.E...... ......I. 0,0-0,0} is not attached to a window
gowtham 6674
01/25/2023, 11:58 AM
Copy code
class CustomInfoWindowAdapter(
val context: Context,
val tickers: List<Hashtable<*, *>>?
) : GoogleMap.InfoWindowAdapter {
override fun getInfoWindow(marker: Marker?): View {
val composeView = ComposeView(context).apply {
setContent {
Text(text = "")
}
}
return composeView
}
override fun getInfoContents(marker: Marker?): View {
val composeView = ComposeView(context).apply {
setContent {
Text(text = "")
}
}
return composeView
}
}
Also you cannot use the context because you need an inflater to attach to the info window as a view
You can use
my_layout.xml
<androidx.compose.ui.platform.ComposeView
android:id="@+id/my_composable"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
val view = LayoutInflater.from(context).inflate(R.layout.my_layout, null, false)
Then use view.findViewById<ComposeView>(R.id.my_composable).setContent { }