Have any attempts at putting a ComposeView inside ...
# compose
m
Have any attempts at putting a ComposeView inside an ArrayAdapter been made?
After varied attempts of 1.
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
2. calling
disposeComposition()
I'm stuck with
Copy code
java.lang.IllegalStateException: Cannot locate windowRecomposer; View androidx.compose.ui.platform.ComposeView{...} is not attached to a window
a
as in for a
ListView
?
m
Specifically an
ArrayAdapter
which extends
BaseAdapter
. It is used in
AutoCompleteTextView
for the dropdown items.
a
I have to admit you're the first person to ask 😄 got a full stack trace?
m
Let me know if there is anything else I can do! https://gist.github.com/maxgdn/cbbf006bcc9357be207594b8678efef1
a
the composition needs a parentCompositionContext set on the view to be able to measure, and AutoCompleteTextView tries to measure unattached views to determine the size of the popup window to create
if a parentCompositionContext isn't present, the ComposeView will search the view tree for one. If it's attached to a window then a window-scoped recomposer will be lazily created at that point
you can install one yourself in the window where the AutoCompleteTextView is attached by doing what this internal property does: https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/WindowRecomposer.android.kt;l=227?q=WindowRecomposer.
m
I believe I understand and will give this an attempt. Thank you Adam 😄
👍 1
a
it should make things easier that we recently opened the create function for this as experimental, so you can at least call that to create one instead of having to copy all of that 🙂
that might only be in the recent alphas, I forget if it was experimental in 1.1 or only
internal
👍 1
540 Views