Hello, I have troubles migrating one of the views ...
# compose
g
Hello, I have troubles migrating one of the views to
ComposeView
using interop. I have a custom view which extends
AbstractComposeView
, then I’m trying to add this view programmatically with
listItem.addView(myComposeView)
inside the
onBindViewHolder
method of RV adapter (inside one of the items). It crashes with
java.lang.IllegalStateException: ViewTreeLifecycleOwner not found from id/listItem
. I’ve tried to debug it and I found that it tries to recursively find a parent with
android.R.id.content
, but the problem with RecyclerView is that sometimes it returns
null
for its children’
getParent()
, because they’re not yet attached to viewholder. So the parent is null means it doesn’t have
ViewTreeLifecycleOwner
. Is it a bug or expected behavior? Should I do it differently? Is there a way to work around it?
a
Go ahead and file a bug for it on the issue tracker with a repro sample and we'll have a look
👍 1